/*****************************************************************/ // File : revdigits.c // Purpose : Display the given number in REVERSE order // Author : Nanda Kishor K N // Mail Id : knnkishor@yahoo.com, nandakishorkn@rediffmail.com // Website : www.c4swimmers.esmartguy.com ( WEB MASTER ) // Group : c4swimmers@yahoogroups.com ( MODERATOR ) /*****************************************************************/ #include /* Name : main() Purpose : This is the main function that accepts a number and displays the given number in REVERSE order. This does not call any other function. Parameter : None */ int main() { // Variable Declarations & Initialization // Naming conventions are used like all integer variables should begin with 'i' int iNum,iTemp,iRem,iSumRev=0; // Accept a number from the user printf("Enter number : "); scanf("%d",&iNum); iTemp = iNum; // Temporary variable // Compute the result or REVERSE the digits of a given number while (iTemp > 0) { iRem = iTemp % 10; iSumRev = (iSumRev * 10) + iRem; iTemp /= 10; } // Displays the result or REVERSE order of a given number printf("\nREVERSE order of %d is %d\n",iNum,iSumRev); return 0; } // End of main() program