201k views
2 votes
Write the definition of a function printLarger , whichhas two int parameters and returns nothing. The functionprints the larger value of the two parameters to standard output ona single line by itself.

User Getsoubl
by
9.0k points

1 Answer

3 votes

Answer:

void printLarger (int num_1, int num_2){

//if else statement for checking the condition

if(num_1 > num_2){

cout<<num_1<<endl; //display the output

}else if(num_1 < num_2){

cout<<num_2<<endl; //display the output

}

}

Step-by-step explanation:

Create the function with return type void, it means the function returns nothing.

The number will be large if it less than the second number.

The possible condition are:

1. number_1 > number_2: the number_1 will be large.

2. number_1 > number_2: the number_2 will be large.

In the programming, if-else is the conditional statement which is used for checking the condition and gives the output accordingly.

Syntax:

if(condition){

statement;

} else if(condition){

statement;

}

when the program executes the if statement checks if condition number_1 > number_2 is true or not if true then print the output.

if the condition false, then the program control move to the else if part and then checks the condition if the condition true then print the output.

User Sebastian Ott
by
8.3k points