Write a program that two-digit number receive and to reverses and print it out? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Write a program that two-digit number receive and to reverses and print it out?

please write it with c++

9th Nov 2016, 1:07 PM
ali Bahrain
ali Bahrain - avatar
2 Answers
+ 2
# include <iostream.h> void main(){ int a; cout<<"Enter the no. to be reversed :"; cin>>a; while(x<10) { cout<<a%10; a/=10; } cout<<a; } my teacher taught me the program... 🏫 it at first print the one digit and then tens digit then hundreds thus the no shown on screen is the reversed no.
9th Nov 2016, 1:14 PM
Sandeep Chatterjee
0
#include <iostream> using namespace std; int main() { int n, reversedNumber = 0, remainder; cout << "Enter an integer: "; cin >> n; while(n != 0) { remainder = n%10; reversedNumber = reversedNumber*10 + remainder; n /= 10; } cout << "Reversed Number = " << reversedNumber; return 0; }
9th Nov 2016, 1:36 PM
Malvern Panashe Mhepo
Malvern Panashe Mhepo - avatar