Practical B Exercise1: A five digit number is entered through the keyboard. Write a program to obtain the reversed number and to determine whether the original and reversed numbers are equal or not.

Posted: September 17, 2012 in CSE Sem1, ECE Sem1, Lab 10B, Lab 10B
#include<stdio.h>
#include<math.h>
void main()
{
	int num,num1,rev=0,p=4,temp;
	printf("Enter num");
	scanf("%d",&num);
	temp=num;
while(num>0)
	{
num1=num%10;
		rev=rev+num1*pow(10,p--);
	num=num/10;
	}
	printf("%d",rev);
	if(rev==temp)
		{
		printf("Reversed no.is equal");
}
	else
	{
		printf("Reversed no. is not equal");
		}
		}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s