I want to compare the size of two numbers and print the larger value in reverse. but, the output value is different from what I expected.
#include<iostream>
int main() {
    int a, b;
    int big;
    std::cin >> a>>b;
    if (a > b)
        big = a;
    if (a <= b)
        big = b;
    std::cout << "input" << a <<" "<< b<<"\n";
    std::cout << "bigger"<<big << "\n";
    
    int q, w, e;
    e = big % 10;
    w = (big % 100)-e;
    q= big - (e)-(w * 10);
    std::cout << e << w << q;
    return 0;
}
- This code receives two integers from the user and stores them in variables a and b.
- It compare two values and store the larger value in the variable called “bigger” by using if statement.
- Store the remainder of division by 10 in q
 The remainder of division by 100 minus q is stored in w
 Subtract q and 10 times w from the value stored in 'bigger' and store the result in 'e'.
- Output value of e,w,q without spaces.
there is some example that I expected.
input
123 456
output
123 456 input123456 bigger456 654
but this is the result.
123 456 input123 456 bigger456 650-50
I searched this question. this question It shows How to print a number backwards with a built-in function. So I asked new question.
 
     
     
    