Users Online

· Guests Online: 7

· Members Online: 0

· Total Members: 188
· Newest Member: meenachowdary055

Forum Threads

Newest Threads
No Threads created
Hottest Threads
No Threads created

Latest Articles

11 C Program to Convert Binary to Octal

This C Program Converts the given Binary to Octal. Binary number is a number that can be represented using only two numeric symbols – 0 and 1. A number in base 2.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.
Here is source code of the C program to Convert Binary 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 Binary to Octal
*/
#include <stdio.h>

int main()
{
long int binarynum, octalnum = 0, j = 1, remainder;

printf("Enter the value for binary number: ");
scanf("%ld", &binarynum);
while (binarynum != 0)
{
remainder = binarynum % 10;
octalnum = octalnum + remainder * j;
j = j * 2;
binarynum = binarynum / 10;
}
printf("Equivalent octal value: %lo", octalnum);
return 0;
}


Output:
$ cc pgm5.c
$ a.out
Enter the value for binary number: 10101
Equivalent octal value: 25

Comments

No Comments have been Posted.

Post Comment

Please Login to Post a Comment.

Ratings

Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Render time: 0.73 seconds
10,923,071 unique visits