123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Program to display decimal equivalent of a input binary number.

--------------------------------------------------------------------------------



#include <stdio.h>
#include <conio.h>
#include <math.h>
void btod(int b[]);
int c;
void main()
{

int a[5],d,i,e,f,g;
clrscr();
printf("What will be the length of input no.? ");
scanf("%d",&c);
printf("Don't exceed input from your input limit or 5 digits in any case");
printf("
Enter no.:- ");
scanf("%d",&d);
for (i=c-1;i>=0;--i)
{
e = pow(10,i);
a[i] = d/e;
d = d%e;
}
btod(a);
printf("




HAVE A NICE DAY! BYE.");
getch();
}

void btod(int b[])
{
int k,s=0,i,n;
n=*b;
for (i=c-1;i>=0;--i)
{
if (i>0)
*b=*(b+i);
else
*b=n;
if (*b==1)
{
k=pow(2,i);
s=s+k;
}
}
printf("
Its decimal equivalent is %d",s);
return;
}
 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG