C Program to Reverse a Number - IProgramX

Q. Write a program to accept an integer and reverse the number


Program

#include<stdio.h>
int main()
{
int a,j=0,p;
printf("enter the no : ");
scanf("%d",&a);
printf("reverse= ");
while(a!=0)
{
p=a%10;
a=a/10;
j++;
printf("%d",p);
}
}

Output:

enter the no : 568
reverse= 865

Post a Comment

0 Comments