Sunday, May 26, 2019

C programming : Program to reverse a number

/* Program to find a reverse of a number */

#include<stdio.h>
#include<conio.h>
void main( )
{
int a,b,c,n,rev;
printf("\n Enter the value of n ");
scanf("%d",&n);
a=n%10;
b=(n/10)%10;
c=(n/10)/10;
rev=a*100+b*10+c*1;
printf("\n The reverse of a given number is %d",rev);
getch();
}

Output 

Enter the value of n
123
The reverse of a given number is321
 
The output will be seen as shown below:
 



No comments:

Post a Comment

Function

FUNCTION C enables programmer to break up a program into segments commonly known as functions, each of which can be written more or...