Skip to content

Instantly share code, notes, and snippets.

@SohanChy
Last active August 29, 2015 14:23
Show Gist options
  • Save SohanChy/c1edb314231b68ba26d3 to your computer and use it in GitHub Desktop.
Save SohanChy/c1edb314231b68ba26d3 to your computer and use it in GitHub Desktop.
Count how many integers are in a number in C
#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