C Program to reverse the digits of an number

Sample Input 1 :

734

Sample Output 1 :

347

Flow Chart Design

C Program to reverse the digits of an number Flow Chart

Try your Solution

Strongly recommended to Solve it on your own, Don't directly go to the solution given below.

#include<stdio.h> int main() { //write your code here }

Program or Solution

				
			
					
#include<stdio.h>
int main()
{
	int num,rev,rem;
	scanf("%d",&num);
	while(num!=0)
	{
		rem=num%10;
		rev=rev*10+rem;
		num/=10;
	}
	printf("Reverse is %d",rev);
	return 0;
}
		
			
				
			

Output

C Program to reverse the digits of an number Output

Program Explanation

refer video tutorial

Comments