mcqs bucket

  • MCQs Bucket | Program Write a Program in C++ that takes a Integer and Reverse it .

    mcqsbucket

      Best guide for exams of all nature, Competitive exams and Interviews

Write a Program in C++ that takes a Integer and Reverse it .

	 
                                 		

#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;
}