Here We will write a Program to reverse the digits of a given integer using looping.
#include<stdio.h>
int main()
{
int n, rev=0, rem;
printf("Enter the no : ");
scanf("%d",&n);
while(n!=0)
{
rem=n%10;
rev=rev*10+rem;
n=n/10;
}
printf("Reverse = %d",rev);
return 0;
}
INPUT : 137
OUTPUT : Reverse = 731
No comments:
Post a Comment