Decimal to Octal November 02, 2011 Get link Facebook X Pinterest Email Other Apps Q. Write a program in C to convert a decimal number to its octal equivalent.Ans.Coding 4 decimal to octal#include<stdio.h>#include<conio.h>void convert(int num, int rem);int main(){ int n,m; printf("Enter number to change in octal: "); scanf("%d",&n); convert(n,m); return 0;}void convert(int num, int rem){ if(rem==0) return; rem=num%8; num=num/8; convert(num,rem); if(rem!=0) printf("%d",rem);}/******************Output************Enter number to change in octal : 7861422 Hence, (786)10=(1422)8**********************************/ Comments
Comments
Post a Comment