From 34bc355f1117fef0008ad6a4fa466c2b2708ea58 Mon Sep 17 00:00:00 2001 From: MohamedSabthar <43032716+MohamedSabthar@users.noreply.github.com> Date: Mon, 28 Oct 2019 22:02:08 +0530 Subject: [PATCH] Create Digit Frequency --- C/Digit Frequency | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 C/Digit Frequency diff --git a/C/Digit Frequency b/C/Digit Frequency new file mode 100644 index 0000000..d64bb4b --- /dev/null +++ b/C/Digit Frequency @@ -0,0 +1,16 @@ +int main() { + int* nums = (int*) malloc(10 * sizeof(int)); + char c; + + for(int i = 0; i < 10; i++) + *(nums+i) = 0; + + while(scanf("%c", &c) == 1) + if(c >= '0' && c <= '9') + (*(nums+(c-'0')))++; + + for(int i = 0; i < 10; i++) + printf("%d ", *(nums+i)); + + return EXIT_SUCCESS; +}