Write a program which counts for the number of digits in an integer number being
entered by user using:
a. For loop
b. While loop
c. Do while loop
#include <stdio.h>
int main()
{
printf("Enter a number : ");
int n;
int count=0;
scanf("%d",&n);
while(n>0)
{
n=n/10;
count++;
}
printf("\nThe number of digits in entered number is : %d",count);
return 0;
}
Comments
Leave a comment