Reverse a number | User given | C-Program
Reverse a number:
Tips:
1.Take variable.
2.Use while loop.
3.Divide the value taken in variable.
Code:
#include<stdio.h>
void main()
{
int a,b=0,c;
printf("Enter a number:\n");
scanf("%d",&a);
while(a!=0)
{
c=a%10;
b=b*10+c;
a/=10;
}
printf("The reverse : %d",b);
getch();
}
Comments
Post a Comment
Give your feedback!
DO NOT SPAM !!
NO THIRD PARTY PROMOTIONAL LINK !!!! (else comment will be deleted.)