1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Mamont248 [21]
4 years ago
6

A function test() that would take three integervalues x, y and z (as

Computers and Technology
1 answer:
marta [7]4 years ago
4 0

Answer: The c++ program to implement test() method is given below.

#include <iostream>

using namespace std;

int test(int a, int b, int c);

int main() {

   int x, y, z;

   cout<<"This program displays the largest number."<<endl;

       cout<<"Enter first number"<<endl;

       cin>>x;

       cout<<"Enter second number"<<endl;

       cin>>y;

       cout<<"Enter third number"<<endl;

       cin>>z;

   int max = test(x, y, z);

   cout<<"The largest number is "<<max<<endl;

   return 0;

}

int test(int a, int b, int c)

{

   if((a>b)&&(a>c))

       return a;

 

   else if((b>a)&&(b>c))

           return b;

           

   else if((c>b)&&(c>a))

           return c;

     

}

OUTPUT

This program displays the largest number.

Enter first number

12

Enter second number

0

Enter third number

-87

The largest number is 12

Explanation:

The method test() is declared as follows.

<em>int test(int a, int b, int c);</em>

The method is declared with return type int since it returns an integer, i.e., the largest of the three parameters.

This program is designed to accept 0 and all values of integers. Hence, input is not tested for validity. It is assumed that the user enters only numerical values.

The program declares and uses three integer variables to store the user input.

<em>int x, y, z;</em>

The method test() is designed to accept three integer parameters. This method is called once the user enters three numbers for comparison.

<em>int test(x, y, z);</em>

These numbers are compared in order to return the largest number.

No variable is used for comparison. The method simply compares the numbers using multiple if-else statements.

<em>if((a>b)&&(a>c))</em>

<em>        return a;</em>

The same comparison logic is applied for other two input values.

The largest number is returned to the calling function which is main() in this program. This value is stored in the integer variable, max, declared in the main() method. The variable max is declared and initialized simultaneously.

<em>int max = test(x, y, z);</em>

This value is then displayed on the screen.

<em>cout<<"The largest number is "<<max<<endl;</em>

You might be interested in
Mối quan hệ giữa đối tượng và lớp
Andreas93 [3]

Answer:

please write in english i cannot understand

Explanation:

8 0
3 years ago
Intellectual property rights protect people’s and organization’s ideas and other intellectual assets. However, in certain cases,
Katarina [22]

Answer:

negative effect

Explanation:

its right on edg

8 0
3 years ago
Tanya purchases a new pair of shoes for $45. The cashier asks her to pay $48. Which of these explains the difference in price?
harina [27]

Answer:

An indirect tax in the form of sales tax

Explanation:

This is certainly the sales tax, and that the shoe retailer is charging with the actual price And each retailer must charge this as they have to submit the sales tax on the number of goods they sell in a year. And these are indirect taxes. Hence, the $45s here is the price of the shoe, and the extra $3s is the sales tax on that shoe. The retailer collects this on behalf of the government, and remember this is an indirect tax.

8 0
4 years ago
Use the Internet identify a problem that social media was used to solve. The problem may be local, national, or global.
ExtremeBDS [4]
What are my options?
5 0
3 years ago
(50 points) {brainliest}
Elena-2011 [213]

C is the answer

bc i know it is

4 0
3 years ago
Read 2 more answers
Other questions:
  • question 4 What is the output of following program: public class Test { public static void main(String[] args) { A a = new A();
    12·1 answer
  • What process combines data from a list with the content of a document to provide personalized documentsWhat
    12·2 answers
  • Create a program that will play the “cows and bulls” game with the user. The game works like this: Randomly generate a 4-digit n
    15·1 answer
  • _____________ data is what is translated to digital format so it can be stored in a computer.
    10·1 answer
  • Which site was launched by Ben t Smith iv
    12·1 answer
  • A recommended cleaner for the bowls of coffee brewers is
    7·1 answer
  • What happens when you apply a theme to a form?
    14·1 answer
  • The four differences between binary and denary​
    13·1 answer
  • Which component is likely to be a performance bottleneck on a workstation used to edit digital movies
    10·1 answer
  • When you try to move the desktop icon using the click and drag method and it doesn't move, what is the reason?​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!