Source Code
// 21.i. Program to count number of digits // Arpan Das - CST 2nd Year (VOCLET) #include <stdio.h> //#include <conio.h> int main() { int num, digits=0; //clrscr(); printf("Please enter any number: "); scanf("%d", &num); while (num != 0) { num /= 10; digits++; } printf("\nNumber of digits: %d", digits); //getch(); }
Output
Please enter any number: 1234
Number of digits: 4
Please enter any number: 720
Number of digits: 3
Please enter any number: 9831098310
Number of digits: 10