Program to print number of digit in a number using while loop in C-language

#include<stdio.h>
int main()
{
    int i=0,n,a;
    printf("Enter the number\n");
    scanf("%d",&n);
    while(n!=0)
    {
        a=n%10;
        n=n/10;
        i++; 
    }
    printf("Number of digit=%d",i);
}

OUTPUT
Enter the number
46378
Number of digit=5

Visit Homepage


Comments

Popular posts

Creative pattern of butterfly in C-language

Program to show present time and date in C-language

Introduction of C-language.

Program to cheque enter number is a perfect number or not using if else in C-language

Program to cheque four digits number is palindrome or not in C-language

Program to print the cube of a number in c-language

Simple Hello world program in c- language