Tuesday, 10 January 2012

Write a C program to convert Binary into Decimal

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

void main()
{
    int mulval=128,mul,num=0,i,a[100];
    clrscr();
    printf("Enter the binary number::\n");
    for(i=0;i<8;i++)
    {
        scanf("%d",&a[i]);
    }

    for(i=0;i<8;i++)
    {
        mul=a[i]*mulval;
        num=num+mul;
        mulval=mulval/2;
    }
    printf("\n\nBinary number is= %d",num);
    getch();
}

No comments:

Post a Comment