luc032.c ​
Metadata ​
- Author — Amit Dutta (amitdutta4255@gmail.com)
- Last updated — 12 Dec 2025
- License — MIT
Problem Statement ​
Problem Statement
Write a program to recieve an integer and find its octal equivalent. (Hint : To obtain octal equivalent of an integer, Divide it continuously by 8 till dividend does not become zero, then write the remainders obtained in reverse derection.)
Source Code ​
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
c
#include <stdio.h>
int main()
{
int octal[20], decimal, index = 0, temp, rem;
printf("Enter the decimal number : ");
scanf("%d", &decimal);
temp = decimal;
while (temp != 0)
{
rem = temp % 8;
temp = temp / 8;
octal[index] = rem;
index++;
}
printf("\nDeciaml %d to octal : ", decimal);
while ((index - 1) >= 0)
{
printf("%d", octal[index - 1]);
index--;
}
return 0;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22