Count Digits of a Number (while loop)

 #include<stdio.h>

int main()

{

    int n,count=0;


    printf("Enter number: ");

    scanf("%d",&n);


    while(n!=0)

    {

        n=n/10;

        count++;

    }


    printf("Total digits = %d",count);

}

Comments

Popular posts from this blog

Single Program Using All Automatic String Functions

C program for subtraction of two matrices (2D Arrays)

C program for Multiplication of Two matrices