Counting the number digits in the given number


 NUMBER OF DIGIT IN THE 
GIVEN NUMBER
Image result for DIGITS



                               This code is to count how many digits in the given number.
For example, We are entering 5627 then the output is 4.Because digits in the given number is 4.

C language code for counting the digits: 

#include<stdio.h>
 #include<conio.h>
 int main()
 {
 int num,a,b=0;
 clrscr();
 printf("Enter an integer: \n");
 scanf("%d",&num);
 a=num;
 while(a!=0)
{ a=a/10;
++b;
}
printf("Number of Digits in %d:%d is ",num,b);
getch();
return 0;
}

------------------------------------------------------------------------------------
Output:
Enter an integer: 7648
Number of Digits in 7648 is 4.


Counting the number digits in the given number Counting the number digits in the given number Reviewed by Amit Waghmare on January 09, 2019 Rating: 5

No comments: