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)

Last Updated: December 30, 2017 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

Top Related Articles:

  1. C++ Program to Find largest element in an array
  2. C++ Program to Find Second Smallest Element in an Array
  3. C++ Program to add two numbers
  4. C++ Program to display Armstrong Numbers between 1 and 1000
  5. C++ Program to Find and display the Transpose of a Matrix

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

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

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap