beginnersbook.com

  • Home
  • All Tutorials
    • Learn Servlet
    • Learn JSP
    • Learn JSTL
    • Learn C
    • Learn C++
    • Learn MongoDB
    • Learn XML
    • Learn Python
    • Learn Perl
    • Learn Kotlin
    • Learn jQuery
  • Core Java
  • OOPs
  • Collections
  • Java I/O
  • JSON
  • DBMS

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

Recently Added..

  • JSON Tutorial
  • Java Regular Expressions Tutorial
  • Java Enum Tutorial
  • Java Annotations Tutorial

Copyright © 2012 – 2022 BeginnersBook . Privacy Policy . Sitemap