adsense

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

Program in C and C++ to Convert Decimal to Octal number Using recursive function

Program in C and C++ to Convert Decimal to Octal number Using recursive function
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



Post a Comment

0 Comments