Program that finds the smallest integer

How would you go about writing a C++ program that finds the smaller of two integers input using an if statement?
It's a very easy question. Take as input two integers, and then confront them, you can have three situations, a>b, a=b, b>a

1
2
3
4
5
6
7
8
9
10
11
12
int a,b;                             
cout << "Give me two numbers: ";
cin >> a >> b;
if (a>b)
      cout << "The smaller is " << b;
else
{
     if (b>a)
            cout << "The smaller is " << a;
    else
          cout << "They have the same value";
}
Last edited on
Topic archived. No new replies allowed.