#include<stdio.h>
#include<conio.h>
int reverse(int n) //Function to reverse a number
{
int rev=0;
int temp;
temp=n;
while(temp!=0)
{
rev=(rev*10)+(temp%10);
temp=temp/10;
reverse(temp/10);
}
return rev;
}
void main()
{
clrscr(); //Clears previous output screen
int n;
printf("Enter a number: ");
scanf("%d",&n);
printf("\nThe reverse of the number is: %d",reverse(n));
getch(); //Wait until you press any key
}
#include<conio.h>
int reverse(int n) //Function to reverse a number
{
int rev=0;
int temp;
temp=n;
while(temp!=0)
{
rev=(rev*10)+(temp%10);
temp=temp/10;
reverse(temp/10);
}
return rev;
}
void main()
{
clrscr(); //Clears previous output screen
int n;
printf("Enter a number: ");
scanf("%d",&n);
printf("\nThe reverse of the number is: %d",reverse(n));
getch(); //Wait until you press any key
}
0 comments:
Post a Comment