C Program binary to decimal | simple c program examples

What is c programming?

C programming is a general-purpose computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system.
Although C programming was designed for implementing system software,It is also widely used for developing portable application software.
C programming is one of the most popular programming languages of all time and there are very few computer architectures for which a C programming compiler does not exist. C has greatly influenced many other popular programming languages.

tutorial for c,c examples source code,simple examples of c programs,simple c program examples

Bellow is c program example for c programming practice

C examples source codes for binary to decimal

/***************************
      author-Nikunj v Gandhi
      from-gujarat(surat)
      Web Developer(ZCE)
      email-nik_gandhi007@yahoo.com
      http://my-source-codes.blogspot.com/
      Description:c program binary to decimal
      ******************************************** */

   #include
   #include
   void main()
    {
     long int n,i=1,d=0,m=0,l=0;
     clrscr();
     printf("Enter binary number");
     scanf("%ld",&n);
     while(n>0)
      {
       m=(n%10);
       n=(n/10);
       l=m*i;
       d=d+l;
       i=i*2;
     }
     printf("%ld",d);
     getch();
     }

Buy Me a Beer-If you are like this post

 If you does not have paypal account create free account create account

2 comments:

Pawan Tejas said...

Thank you!
Really it's a great help for me.

Anonymous said...

similar code for decimal to binary
int i, j, n=25, p=1, r, bin =0;
for(i=n;i>=1;i=i/2) {
r = i%2;
bin = bin+(p*r);
p = p*10;
}
printf("%d",bin);

Post a Comment