+ 1
Write a program that two-digit number receive and to reverses and print it out?
please write it with c++
2 odpowiedzi
+ 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.
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;
}