#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
long int decimal_num, rem, quotient;
int i=1, j, octal_num[100];
printf("\n Enter any decimal number : ");
scanf("%ld",&decimal_num);
quotient=decimal_num;
while(quotient!=0)
{
octal_num[i++]=quotient%8;
quotient=quotient/8;
}
printf("\n Equivalent octal value of %d is : \n",decimal_num);
for(j=i-1; j>0; j--)/*Array in reverse order*/
{
printf("\t %d",octal_num[j]);
}
getch();
}
Run1:
Run2:
Previous Next
#include<conio.h>
void main()
{
clrscr();
long int decimal_num, rem, quotient;
int i=1, j, octal_num[100];
printf("\n Enter any decimal number : ");
scanf("%ld",&decimal_num);
quotient=decimal_num;
while(quotient!=0)
{
octal_num[i++]=quotient%8;
quotient=quotient/8;
}
printf("\n Equivalent octal value of %d is : \n",decimal_num);
for(j=i-1; j>0; j--)/*Array in reverse order*/
{
printf("\t %d",octal_num[j]);
}
getch();
}
Run1:
Run2:
Previous Next
No comments:
Post a Comment