c++ help

Write a C++ program that find the smaller of two integers input using an if statement
Try reading a bit about conditional operators
http://www.cplusplus.com/doc/tutorial/operators/
And the if statement
http://www.cprogramming.com/tutorial/lesson2.html
Last edited on
Is this what you are looking for??

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <conio.h>
using namespace std;


int main(){

double first = 0;   // Variables are locally declared
double second = 0;

cout << "Enter the first number" << endl;
cin >> first;
cout << "Enter the second number" << endl;
cin >> second;

if(first > second){
    cout << "First number is greater than the second number\n" << endl;
    cout << first <<" > " << second << endl;
}else{
    cout <<  "Second number is greater than the first number\n"<< endl;
    cout << second << " > " << first << endl;
}
getch();

return 0;
}
Topic archived. No new replies allowed.