Answer to Question #238416 in C++ for asad

Question #238416

Write a function which takes two integers as parameter and return the largest number. Demonstrate the function using a program (call that function). Display the largest number in main function


1
Expert's answer
2021-09-17T02:04:37-0400
#include <iostream>

using namespace std;

int thelargest(int a, int b){
	return a > b ? a : b;
}

int main(int argc, char *argv[])
{
	cout << "Enter the numbers: a then b" << endl;
	int a, b;
	cin >> a >> b;
	cout << thelargest(a, b);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS