Problem Statement : Write a C Program to Find the Number of Digits in an entered number ?
#include<stdio.h> #include<string.h> void main() { int num,digits; char ch[10]; printf("\nEnter the Number : "); scanf("%d",&num); sprintf(ch,"%d",num); digits = strlen(ch); printf("\nNumber of Digits : %d",digits); getch(); }
Output:
Enter the Number : 1234 Number of Digits : 4