Saturday, August 20, 2011

Convert binary number to decimal number.

//Program to convert binary number to decimal number.
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
 long int num;
 int r,n,i=0,k=-1;
 clrscr();
 printf("program to convert binary to decimal");
 printf("\n Enter the number: ");
 scanf("%ld",&num);
 while(num>0)
 {
  k=k+1;
  r=num%10;
  num=num/10;
  i=i+r*pow(2,k);
 }
 printf("The decimal equivalent is=%d ",i);
 getch();
}

Previous Next Home
0 Comments
Comments

Leave a Comment

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Twitter Delicious Facebook Favorites More