Users Online
· Guests Online: 148
· 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
19 C Program to Convert Octal to Decimal
This C Program Converts the given Octal to Decimal. 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 Octal to Decimal. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
/*
* C Program to Convert Octal to Decimal
*/
#include <stdio.h>
#include <math.h>
int main()
{
long int octal, decimal = 0;
int i = 0;
printf("Enter any octal number: ");
scanf("%ld", &octal);
while (octal != 0)
{
decimal = decimal +(octal % 10)* pow(8, i++);
octal = octal / 10;
}
printf("Equivalent decimal value: %ld",decimal);
return 0;
}
Output:
$ cc pgm3.c -lm
$ a.out
Enter any octal number: 67
Equivalent decimal value: 55
Here is source code of the C program to Convert Octal to Decimal. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
/*
* C Program to Convert Octal to Decimal
*/
#include <stdio.h>
#include <math.h>
int main()
{
long int octal, decimal = 0;
int i = 0;
printf("Enter any octal number: ");
scanf("%ld", &octal);
while (octal != 0)
{
decimal = decimal +(octal % 10)* pow(8, i++);
octal = octal / 10;
}
printf("Equivalent decimal value: %ld",decimal);
return 0;
}
Output:
$ cc pgm3.c -lm
$ a.out
Enter any octal number: 67
Equivalent decimal value: 55
Comments
No Comments have been Posted.
Post Comment
Please Login to Post a Comment.