In this program we are using if..else statement to find out the largest of two numbers entered by user.
Example: Program to find the largest of two entered numbers
#include <iostream> using namespace std; int main() { int num1, num2; cout<<"Enter first number:"; cin>>num1; cout<<"Enter second number:"; cin>>num2; if(num1>num2) { cout<<"First number "<<num1<<" is the largest"; } else { cout<<"Second number "<<num2<<" is the largest"; } return 0; }
Output:
Leave a Reply