Created
November 11, 2018 08:29
-
-
Save ThePratikSah/d777b76d5a5419105557f79ad715f053 to your computer and use it in GitHub Desktop.
Digits counter from a number
This file contains hidden or 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 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