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
- program in c++ to find the reverse of a given number
- Program in C to reverse given number
- Program in C to print reverse of a given number in different ways (100 rev 001)Program in C++ to reverse a given string
- Write a program in C to reverse the given string.
- Program in C++ to create function in String class to find reverse of given string
- Program in C to check the given string is palindrome or not.
0 Comments