Write a  C++ Program to Find Largest Number Among Three Numbers

C++ Program to Find Largest Number Among Three Numbers

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn C++ programming concepts. You can learn C++ language at your own speed and time. One can learn concepts of C++ language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

C++ Program to Find Largest Number Among Three Numbers
C++ Program to Find Largest Number Among Three Numbers

Write a  C++ Program to Find Largest Number Among Three Numbers

1. PROGRAM: C++ Program to Find Largest Number Among Three Numbers

/* C++ Program to Find Largest Number Among Three Numbers */

#include <iostream>
using namespace std;

int main() {

double n1, n2, n3;

cout << “Enter three numbers: “;
cin >> n1 >> n2 >> n3;

// check if n1 is the largest number
if(n1 >= n2 && n1 >= n3)
cout << “Largest number: ” << n1;

// check if n2 is the largest number
else if(n2 >= n1 && n2 >= n3)
cout << “Largest number: ” << n2;

// if neither n1 nor n2 are the largest, n3 is the largest
else
cout << “Largest number: ” << n3;

return 0;
}

Leave a Reply

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