/*Program to rerverse a given n-digit number*/ /*Date : 01:12:98*/ main() { int a,x,y,v,b,c,d,f,e,z,flag; clrscr(); z=1; while(z!=0) { clrscr(); printf("\n\n\t\t\t WELCOME TO THE REVERSE WIZARD !"); printf("\n\n\t\tThis program will help you to display the reverse \n\t\torder of a given integer.\n\n\t\tIt will also verify whether the given integer is\n\t\tEqual to it's Reverse order or not.\n\n\t\t\tPress 1 to Continue Or 0 to Quit : "); scanf("%d",&z); flag=1; switch(z) { case 1: printf("\n\n\t\t\t * Enter any integer : "); scanf("%d",&a); x=a; y=a; v=0; if((a>=32767)||(a<=-32767)) { clrscr(); for(v=0;v<5;v++) printf("\n"); printf("\n\n\t\t\t\t INPUT ERROR !\n\n\t\t THE INPUT VALUE EXEEDS THE ACCEPTIBILITY OF YOUR P.C\n\n\t\t Your p.c is not authorised to accept values \n\t\t greater than +32767 And lesser than -32767."); printf("\n\n\n\t\tYou will have to Exit & ReRun the program to Resume....."); getch(); exit(); } else { printf("\n\n\t\t\t\t A N S W E R"); printf("\n\n\t\t The reverse order of the integer is : "); while(a!=0) { b=a%10; if(b<0) { clrscr(); for(v=0;v<4;v++) printf("\n"); printf("\n\n\n\n\n\n\n\t\t\t\t INPUT ERROR !\n\n\t\t PROCESSING HALTED FOR CONFORMATION.....\n\n\t\t\t Press any key to continue....."); getch(); flag=0; break; } if(flag==0) break; printf("%d",b); v=v+1; a=a/10; } c=1; d=0; while(d<(v-1)) { c=c*10; d=d+1; } f=0; e=0; while(x!=0) { b=x%10; e=b*c; f=f+e; x=x/10; c=c/10; } if(flag==0) break; if(f==y) printf("\n\n\t\t The Number is Equal to it's Reverse Order."); else printf("\n\n\t\t The Number is Not Equal to it's Reverse Order."); printf("\n\n\n\t\t\t Press any key to continue....."); getch(); break; case 0: clrscr(); printf("\n\n\n\n\n\n\n\t\t\t\tPROGRAM TERMINATED !\n\n\t\t\t Press any key to Exit....."); getch(); break; default:clrscr(); printf("\n\n\n\n\n\n\n\t\t\t\t INVALID INPUT !\n\n\t\t\t Press any key to try again....."); getch(); break; } } } }