Write a C program to Count Number of Digits in an Integer
Program:-
#include <stdio.h>
int main()
{
int n;
int count = 0;
printf(“\nEnter the number: “);
while(n != 0)
{
n = n/10;
++count;
}
printf(“\nNumber of digits: %d\n”, count);
}
return(0);
}
int main()
{
int n;
int count = 0;
printf(“\nEnter the number: “);
while(n != 0)
{
n = n/10;
++count;
}
printf(“\nNumber of digits: %d\n”, count);
}
return(0);
}
Output:-
....
0 comments:
Post a Comment