Users Online
· Guests Online: 142
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Newest Threads
No Threads created
Hottest Threads
No Threads created
Latest Articles
Articles Hierarchy
13 C program to Convert Decimal to Octal
This C Program Converts the given Decimal to Octal. Octal is a numbering system that uses eight digits, 0 to 7, arranged in a series of columns to represent all numerical quantities. Each column or place value has a weighted value of 1, 8, 64, 512, and so on ranging from right to left. Decimal is a term that describes the base-10 number system commonly used by lay people in the developed world.
Here is source code of the C program to Convert Decimal to Octal. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
/*
* C program to Convert Decimal to Octal
*/
#include
int main()
{
long decimalnum, remainder, quotient;
int octalNumber[100], i = 1, j;
printf("Enter the decimal number: ");
scanf("%ld", &decimalnum);
quotient = decimalnum;
while (quotient != 0)
{
octalNumber[i++] = quotient % 8;
quotient = quotient / 8;
}
printf("Equivalent octal value of decimal no %d: ", decimalnum);
for (j = i - 1; j > 0; j--)
printf("%d", octalNumber[j]);
return 0;
}
Output:
$ cc pgm11.c
$ a.out
Enter the decimal number: 68
Equivalent octal value of decimal no 68: 104
Here is source code of the C program to Convert Decimal to Octal. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
/*
* C program to Convert Decimal to Octal
*/
#include
int main()
{
long decimalnum, remainder, quotient;
int octalNumber[100], i = 1, j;
printf("Enter the decimal number: ");
scanf("%ld", &decimalnum);
quotient = decimalnum;
while (quotient != 0)
{
octalNumber[i++] = quotient % 8;
quotient = quotient / 8;
}
printf("Equivalent octal value of decimal no %d: ", decimalnum);
for (j = i - 1; j > 0; j--)
printf("%d", octalNumber[j]);
return 0;
}
Output:
$ cc pgm11.c
$ a.out
Enter the decimal number: 68
Equivalent octal value of decimal no 68: 104
Comments
No Comments have been Posted.
Post Comment
Please Login to Post a Comment.