#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
long int i=0;
char octal_num[1000];
printf("\n Enter any Octal Number : ");
scanf("%s",octal_num);
printf("\n Equivalent Binary Value = ");
while(octal_num[i])
{
switch(octal_num[i])
{
case '0' : printf("000");
break;
case '1' : printf("001");
break;
case '2' : printf("010");
break;
case '3' : printf("011");
break;
case '4' : printf("100");
break;
case '5' : printf("101");
break;
case '6' : printf("110");
break;
case '7' : printf("111");
break;
default : printf("\nInvalid Octal Digit %c",octal_num[i]);
break;
}
i++;
}
getch();
}
Run1:
Run2:
Previous Next
#include<conio.h>
void main()
{
clrscr();
long int i=0;
char octal_num[1000];
printf("\n Enter any Octal Number : ");
scanf("%s",octal_num);
printf("\n Equivalent Binary Value = ");
while(octal_num[i])
{
switch(octal_num[i])
{
case '0' : printf("000");
break;
case '1' : printf("001");
break;
case '2' : printf("010");
break;
case '3' : printf("011");
break;
case '4' : printf("100");
break;
case '5' : printf("101");
break;
case '6' : printf("110");
break;
case '7' : printf("111");
break;
default : printf("\nInvalid Octal Digit %c",octal_num[i]);
break;
}
i++;
}
getch();
}
Run1:
Run2:
Previous Next
No comments:
Post a Comment