This Program converts a Binary number to a decimal number. This is a part of Mumbai University MCA Colleges C program MCA Sem 1
#include<conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
clrscr();
int sum=0,bin,i=0,rem;
printf("\n Enter binary number:");
scanf("%d",&bin);
while(bin!=0)
{
rem=bin%10;
bin=bin/10;
sum=sum+(rem*pow(2,(i++)));
}
printf("\nThe decimal equivalent is %d",sum);
getch();
}
Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.
#include<conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
clrscr();
int sum=0,bin,i=0,rem;
printf("\n Enter binary number:");
scanf("%d",&bin);
while(bin!=0)
{
rem=bin%10;
bin=bin/10;
sum=sum+(rem*pow(2,(i++)));
}
printf("\nThe decimal equivalent is %d",sum);
getch();
}
Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.
Download
No comments:
Post a Comment