Last active
August 29, 2015 14:23
-
-
Save SohanChy/c1edb314231b68ba26d3 to your computer and use it in GitHub Desktop.
Count how many integers are in a number in C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int countnums(int x); | |
int main() | |
{ | |
int input; | |
scanf("%d",&input); | |
printf("%d",countnums(input)); | |
} | |
int countnums(int x) | |
{ | |
int count; | |
for(count=0;x!=0;count++) | |
{ | |
x=x/10; | |
} | |
return count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment