-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path03_If-else.cpp
More file actions
18 lines (15 loc) · 909 Bytes
/
03_If-else.cpp
File metadata and controls
18 lines (15 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//This is a simple program to TAKE INPUT FROM USERS AND PRINT THE LARGEST VALUE AMONG THEM! This is a simple approach to the problem.
#include <iostream>
using namespace std; //thse two lines are common and required in all teh programs
int main() {
int a,b; //here we are defining two inputs that are going to be integer. Use "char" for string values
cout << "Enter two numbers : " <<endl; //asking the users to enter two input numbers
cin >>a >>b; //assigning the input values to a and b
cout << "You have entered " <<a <<" and " <<b <<endl; //printing the numbers provided as input by the user
if(a>b){ //writing the first condition to check whether a is greater than b
cout << "The largest number is : " << a <<endl; //if the condition is satisfied, output is printed
}
else{
cout <<" The largest number is : " <<b <<endl; //program will print this as output if the condition is not met above
}
}