BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

C++ Program to Find Largest of Two Numbers(Entered by User)

By Chaitanya Singh | Filed Under: C++ Programs

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:
C++ Program to find largest of two numbers

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Programs

  • C Programs
  • Java Programs
  • C++ Programs

Copyright © 2012 – 2022 BeginnersBook . Privacy Policy . Sitemap