GoHacking.com: Ethical Hacking and Cyber Security
Home » C PROGRAMMING

C Program to display the No. of Digits in an Entered Number

Submitted by on Monday, 3 December 20073 Comments

This program displays the number of digits present in the number that is entered through the input.

#include<stdio.h>
#include<conio.h>

void main()
{
unsigned long int num;
int i=0;
clrscr();
printf(“Enter the digit\n”);
scanf(“%lu”,&num);
while(num!=0)
{
num=num/10;
++i;
}
printf(“Length=%d”,i);
getch();
}



By using/following this site you agree to our Legal Disclaimer

3 Comments »

  • OSBAMA said:

    I DON’T KNOW WHAT KIND OF COMPILER DO YOU HAVE, BUT DEV REPORTS 4 OR 5 5 MISTAKES. WHY IS THAT HAPPENING.

  • TanzeelurRehman said:

    @osbama,

    Basically when you copy the program and use in Dev C++, then do following things
    1) use int main instead of void main
    2) Remove clrscr();
    3) Correct the qoutes (“”), where ever in the program, Dev C++ doesnot recognize them as a qoute.

    and then you will have your programe working

    Regards
    TanzeelurRehman

  • alex said:

    and it can’t display more than 10…
    example… you input “54654651651654″, and the program says “Length=10″ :)

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.