#include <stdio.h>
#include<conio.h>
void main()
{
clrscr();
long int binary_num, hexa_decimal_num=0;
int i=1, rem;
printf("\n Enter the binary number:");
scanf("%ld",&binary_num);
while(binary_num!=0)
{
rem = binary_num % 10;
hexa_decimal_num = hexa_decimal_num + rem * i;
i = i * 2;
binary_num = binary_num / 10;
}
printf("\n Equivalent Octal value = %lX", hexa_decimal_num);
getch();
}
Run1:
Run2:
Previous Next
#include<conio.h>
void main()
{
clrscr();
long int binary_num, hexa_decimal_num=0;
int i=1, rem;
printf("\n Enter the binary number:");
scanf("%ld",&binary_num);
while(binary_num!=0)
{
rem = binary_num % 10;
hexa_decimal_num = hexa_decimal_num + rem * i;
i = i * 2;
binary_num = binary_num / 10;
}
printf("\n Equivalent Octal value = %lX", hexa_decimal_num);
getch();
}
Run1:
Run2:
Previous Next
No comments:
Post a Comment