Thursday, 29 September 2011

Program to find total no. of digit in a given no.

/* WAP to print the total no. of digit in a given number. Eg. If the entered no. is 13423 then print the total no. pf digit =5 and for 34 total no. of digit=2 */


#include<stdio.h>

#include<conio.h>
void main()
{
int n,i=0,t=0;
clrscr();
for(i=n;i>0;i=i/10)
t++;
printf("The total no. of digit = %d ",t);
getch();
}






Note: This program is only for integer data types that means it will give correct output for max value entered 32767 and greater than this no. output will be 0 beacause of incorrect data specifier..

No comments:

Post a Comment