adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Write a program in C to convert decimal into octal number.

Write a program in C to convert decimal into octal number.

#include<stdio.h>
#include<conio.h>
 void main()
  {
   long int dec,oct=0,base=1;
   clrscr();
   printf("Enter a decimal no.:-");
   scanf("%ld",&dec);
   oct=0;
   while(dec!=0)
     {
      oct=dec%8*base+oct;
      dec/=8;
      base*=10;
  }
   printf("The octal equivalent=%ld",oct);
   getch();
   }
Output:-
Related programs:
  1. Write a program in C to Convert  Decimal to Binary number.


Post a Comment

0 Comments