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 print reverse of a given number using recursive function

Program in C and C++ to print reverse of a given number using recursive function


C++ Program
#include<iostream>
 using namespace std;
 void reverse(int n){
    if(n == 0)
        return;
    cout<<n % 10;
    reverse(n / 10);
 }
 int main()
  {
    int n;
    cout<<"Enter a number :- ";
    cin>>n;
    cout<<"Reverse : ";
    reverse(n);
    return 0;
  }
C Program
#include<stdio.h>
 void reverse(int n){
    if(n == 0)
        return;
    cout<<n % 10;
    reverse(n / 10);
 }
 int main()
  {
    int n;
    printf("Enter a number :- ");
    scanf("%d",&n);
    printf("Reverse : ");
    reverse(n);
    return 0;1
  }
Output :-








Related Programs 

Post a Comment

0 Comments