Skip to content

Instantly share code, notes, and snippets.

@ThePratikSah
Created November 11, 2018 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThePratikSah/d777b76d5a5419105557f79ad715f053 to your computer and use it in GitHub Desktop.
Save ThePratikSah/d777b76d5a5419105557f79ad715f053 to your computer and use it in GitHub Desktop.
Digits counter from a number
#include<stdio.h>
int main(){
int num, count = 0;
printf("Enter any number:");
scanf("%d", &num);
if(num == 0)
count = 1;
else{
while(num != 0){
num = num / 10;
count++;
}
}
printf("Number of digits: %d", count);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment