Wednesday, 29 October 2014

Convert the decimal number to octal number


Convert the decimal number to octal number




/*WAP to convert the decimal number to octal number*/

#include<stdio.h>
#include<conio.h>
void main()
{
int dec,oct=0,d,t=1;
clrscr();
printf("enter the decimal number:");
scanf("%d",&dec);
while(dec!=0)
{
d=dec%8;
oct=oct+(d*t);
t=t*10;
dec=dec/8;
}
printf("the octal number is %d",oct);
getch();
}

OUTPUT:
enter the decimal number:10

the octal number is 12

No comments:

Post a Comment