Program to Convert Binary to Decimal.


#include <stdio.h>


int main()

{

    int binary,decimal=0,base=1,rem;

    printf("enter the value of binary");

    scanf("%d",&binary);

    int num=binary;

    while(num>0){

        rem=num%10;

        decimal=decimal+rem*base;

        base=base*2;

        num=num/10;

    }

    printf("the decimal of %d is %d",binary,decimal);

    return 0;

}


No comments:

Post a Comment

Programming in C Language

  PROGRAM LIST TO BECOME PRO IN C    😍😍😍            PRACTICE SETS                                                        UNIT -1  👇   IN...