/* EXPERIMENT - 5 */ /* AIM : TO PRINT THE REVERSE OF A GIVEN INTEGER AND FIND WHETHER THE INTEGER IS EQUAL TO IT'S REVERSE ORDER OR NOT. */ /* PROGRAMMER : SHEKHAR A. SHERIKAR */ /* COMPUTER TECHNOLOGY - CM102 (B3) */ main() { long int a,x,y,v,b,c,d,f,e; int loop,message; clrscr(); loop=1; while(loop!=0) { clrscr(); printf("\n\t\t\t\t - REVERSE MASTER -\n"); printf("\n\t\tThis program will help you to evaluate the reverse order "); printf("\n\t\ta given n-digit integer and print wheather it is equal to"); printf("\n\t\tthe original number or not."); printf("\n\n\t\t\t Type 1 to continue and 0 to exit : "); scanf("%d",&loop); switch(loop) { case 1 : printf("\n\n\t\t\t* Enter the integer to be reversed : "); scanf("%ld",&a); x=a; y=a; v=0; printf("\n\n\n\t\t\t\t\tA N S W E R"); printf("\n\n\t\t The reverse order of the entered integer is : "); message=0; while(a!=0) { b=a%10; printf("%ld",b); v++; message++; a=a/10; } if(message>9) { clrscr(); printf("\n\n\n\n\n\n\n\t\t\t\t INPUT ERROR !"); printf("\n\n\n\t\t INPUT VALUE EXEEDS COMPARISION CAPABILITY !"); printf("\n\n\n\n\n\t\t\t Press any key to continue....."); getch(); break; } c=1; d=0; while(d<(v-1)) { c=c*10; d++; } f=0; e=0; while(x!=0) { b=x%10; e=b*c; f=f+e; x=x/10; c=c/10; } if(f==y) { printf("\n\n\t\t\tThe number is equal to it's reverse order."); printf("\n\n\n\n\t\t\t\tPress any key to continue....."); } else { printf("\n\n\t\t\tThe number is not equal to it's reverse order."); printf("\n\n\n\n\t\t\t\tPress any key to continue....."); } getch(); break; case 0 : clrscr(); printf("\n\n\n\n\n\n\n\t\t\t\tPROGRAM TERMINATED !"); printf("\n\n\n\t\t Press any key to return to source file....."); getch(); break; default: clrscr(); printf("\n\n\n\n\n\n\n\t\t\t\tINVALID INPUT !"); printf("\n\n\n\t\t\tPress any key to continue........"); getch(); break; } } }