C program to convert decimal into octal.

 

01  #include <stdio.h>
02
03 int main()
04 {
05 long decimal;
06 int remainder;
07 long octal = 0, i = 1;
08 printf("Enter a decimal numbern");
09 scanf("%ld", &decimal);
10
11 while(decimal != 0)
12 {
13 remainder = decimal%8;
14 octal = octal + (remainder*i);
15 decimal = decimal/8;
16 i = i*10;
17 }
18
19 printf("Octal number : %ld", octal);
20
21 return 0;
22 }
 
 OUTPUT :

Enter a decimal number : 100
Octal number : 144

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *