Beta Coder

Learn code like Beta Coder.

Breaking

Sunday, August 16, 2020

C Program to Count no. of digits of an integer number

COUNT NO OF DIGITS OF AN INTEGER NUMBER

COUNT NO OF DIGITS OF AN INTEGER NUMBER
In this program we learn how to calculate no. of digits of an integer number provided by user using C.
Example:

 Input : N = 18082020
 Output: No. of digits = 8

 Input : N = 0123456789
 Output: No. of digits = 10
C program to count no. of digits of an integer number
// Count no. of digits of an integer number
#include <stdio.h>
#include <conio.h>
void main()
{
	unsigned long int N,c=0;
	clrscr();
	printf("\n Enter an integer number : ");
	scanf("%u",&N);
        do
        {
    	     c++;
    	     N = N/10;
        }while(n!=0);
	printf("\n  The number of digits = %u",c);        
	getch();
}
OUTPUT:
   Enter an integer number : 18082020
   The number of digits = 8

No comments:

Post a Comment