/* write a c program to reverse a number */
#include<stdio.h>
#include<conio.h>
void main()
{
int n,rev=0;
clrscr();
printf("Enter the number::\n");
scanf("%d",&n);
while(n!=0)
{
rev=rev*10;
rev=rev+n%10;
n=n/10;
}
printf("Reverse of the given number is= %d",rev);
getch();
}
Output of program:
#include<stdio.h>
#include<conio.h>
void main()
{
int n,rev=0;
clrscr();
printf("Enter the number::\n");
scanf("%d",&n);
while(n!=0)
{
rev=rev*10;
rev=rev+n%10;
n=n/10;
}
printf("Reverse of the given number is= %d",rev);
getch();
}
Output of program:
No comments:
Post a Comment