user to count the number of digits in the number entered by user. suppose that
number entered is 56476 then it will tell us 5 digits are there in the number.
Isn't interesting so lets see the program.
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int
n,sum=0,count=0,rem;
printf("Enter the number:");
scanf("%d",&n);
do {
count++;
n=n/10;
}
while(n!=0);
printf("No
of digits in the entered number is:%d\n",count);
}
Output:
count++ : This is an increment operator used to just increase the counting every time it counts one number and it it done by using n=n/10 this reaches every number.
Post a Comment