No Loops, No Problem: Mastering Digit Reversal in C++

Problem Description:

No Loops, No Problem: Mastering Digit Reversal in C++

Write a C++ program that takes a three-digit number as input and prints the

number with its digits reversed. For example, if the input is 123, the output

should be 321.

Task:

1. Declare a variable to store the three-digit number.

2. Use arithmetic operations (division and modulus) to extract the digits of

the number.

3. Rearrange and print the digits in reverse order.

Input Format:

● Take three digit number from user e.g 123

Output Format:

● The number with its digits reversed. E.g 321

Solution:


Code:

#include <iostream>

using namespace std;

int main(){

cout<<"Rearrange and Print the Digits in Reverse Order"<<endl;

cout<<"-----------------------------------------------"<<endl;


int num;


cout<<"Enter Number for Reverse: "<<endl;

cin>>num;


int last_number=num%10;

int middle_number=(num/10)%10;

int first_number=num/100;


cout<<last_number<<middle_number<<first_number;


    return 0;

}



Output:


Thanks......




C++ reverse digits recursion, no loop digit reversal C++, C++ print digits backwards, reverse number without loop C++, C++ digit manipulation tutorial, recursive digit reverse C++ example, C++ string to int reverse, non-loop digit reverse C++ function, C++ problem solving reverse digits, C++ reverse integer recursion method





Comments

Popular posts from this blog

Instagram Data Breach Allegations (January 2026): A Technical Analysis from a Cybersecurity Perspective

Arduino Based Fire Fighting Robot

Master Your Finances: C++ Program to Calculate Monthly Expenses!