C Program to reverse a 3 digit number
In this program, we are getting a 3 digit number as input from the user and reversing that number.
Example : pgm.c
#include<stdio.h> void main() { int num,a,b,c,rev; printf("Enter 3 Digit Number : "); scanf("%d",&num);//For ex input is 123 a=num%10; //3 num=num/10; //12 b=num%10; //2 c=num/10; //1 rev=(a*100)+(b*10)+c; printf("The Reverse Number is %d",rev); }
Output:
Enter 3 Digit Number : 758
The Reverse Number is 857
The Reverse Number is 857
- Divide Operator (/) is used to find quotient(converted to Integer).
- The modulus operator (%) is used to find remainder after the division of an integer.