Program in C and C++ to Convert Decimal to Octal number Using recursive function
Related Programs
C Program
#include<stdio.h> void decToOct(int n){ if( n == 0) return; decToOct( n / 8); printf("%d",n % 8); } int main(){ int n; printf("Enter decimal number :- "); scanf("%d",&n); printf("Octal : "); decToOct(n); return 0; }
C++ Program
#include<iostream> using namespace std; void decToOct(int n){ if( n == 0) return; decToOct( n / 8); cout<<n % 8; } int main(){ int n; cout<<"Enter decimal number :- "; cin>>n; cout<<"Octal : "; decToOct(n); return 0; }
Output :-
Related Programs
- Program in C & C++ to print the binary equivalent 1 to nth number.
- Program in C++ to Convert Binary to Decimal number Using Function
- Program in C to convert decimal into octal number.
- Program in C++ to Convert Hexadecimal to Decimal number Using Function
- Program in C++ to Convert Decimal to Hexadecimal number Using Function
- Program in C to Convert Decimal to Binary number.
- Program in C to print the binary equivalent 1 to nth number.
- Program in C and C++ to Convert Decimal to Binary number Using recursive function
- Program in C and C++ to Convert Binary to Decimal number Using recursive function
0 Comments