WAP in C program to Convert Decimal Number to Octal Number?

#include<stdio.h>
#include<conio.h>
int main()
{
long dnum, quotient;
int onum[100], i = 1, j;
clrscr();
printf(“Enter the decimal number: “);
scanf(“%ld”, &dnum);
quotient = dnum;
while (quotient != 0)
{
onum[i++] = quotient % 8;
quotient = quotient / 8;
}
printf(“Equivalent octal value of decimal no %d: “, dnum);
for (j = i – 1; j > 0; j–)
printf(“%d”, onum[j]);
getch();
return(0);
}

Output:-

DecToOct

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s