Reverse number

Program:

#include<stdio.h>
int main()
{
int n,rev=0,rem;
printf("Enter number: ");
scanf("%d",&n);
while(n>0)
{
rem=n%10;
rev=rev*10+rem;
n=n/10;
}
printf("Reverse of number= %d",rev);
return 0;
}

Output:


No comments:

Post a Comment

x^y using recursion

Program: #include<stdio.h> int power(int a,int b); int main() { int x,y,ans; printf("Enter x and y:\n "); scanf(...