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:
0 Comments