Wednesday, 9 September 2015

C++ Program to print greatest of two numbers

This program asks the user to input two numbers and outputs the greatest of the two numbers.

#include <iostream.h>

void main()
{
int a,b;
cout << "Enter a number : ";
cin >>  a;
cout << "\nEnter another number : ";
cin >> b;
cout << "The largest number is : " << a>b:a?b;
}

If you need explanations, just comment. :D

No comments:

Post a Comment