Program to enter an integer and output it in the reversed form 1 Attachment(s) Program to enter an integer and output it in the reversed form #include #include void main() { clrscr(); long int num1,num2,rnum=0; cout << "Enter an integer : " << endl; cin>>num1; num2=num1; do { rnum=rnum*10; int digit=num1%10; rnum+=digit; num1/=10; } while(num1); cout << "The integer you typed is " << num2 << "." << endl; cout << "The reversed integer is " << rnum << "." << endl; getch(); } It then outputs the integer in its reversed form using the 'cout' command. Sample Input 987 Sample Output The integer you typed is 987. The reversed integer is 789. |
All times are GMT +5. The time now is 03:00 PM. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.