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]
3 years ago
6

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

Computers and Technology
1 answer:
marta [7]3 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
A digital clock on a small cooking appliance keeps time by?
IgorLugansk [536]
They typically use the 50-60 Hz oscillation of AC power or a 32,768 hertz Chrystal oscillator to keep time. <span />
5 0
3 years ago
The ______ is the information center that drivers need to refer to when they're NOT scanning the road.
Arisa [49]

Answer:

C. instrument panel

Explanation:

In order to be able to operate your vehicle safely, you must know the functions and locations of all the interior mechanisms of your car.

The instrument panel contains gauges which include the following:

Speedometer, which indicates speed in both miles and kilometers per hour

Tachometer, which indicates rotations in the engine in revolutions per minute (RPMs)

Odometer, which indicates the total number of miles your car has been driven since it was manufactured

Fuel gauge, which shows the fuel level in your car's fuel tank

Oil gauge, which shows oil level

5 0
3 years ago
What are the answers to 14 and 15
RoseWind [281]
The answer to 14 is c and the answer to 16 is a
6 0
4 years ago
The ____ cell on the worksheet is the one into which you can enter data.â
Illusion [34]

I guess the best answer is Active.

The Active cell on the worksheet is the one into which you can enter data.

3 0
3 years ago
Read 2 more answers
Select the correct answer.
IrinaK [193]
The answer is the letter (D)
4 0
3 years ago
Other questions:
  • A(n) ____ is a client, server, or other device that can communicate over a network and is identified by a unique number, known a
    10·1 answer
  • Adjusting the ______ adjusts the difference in appearance between light and dark areas of the photo.​
    10·2 answers
  • ___signs tell you what you can or can't do, and what you must do ?
    5·2 answers
  • What feature, new to Windows Server 2012, provides the ability to find identical sets of data on a SAN-based storage array and r
    13·1 answer
  • Qué es un bloque de programación?
    5·1 answer
  • Please answer<br><br>NO LINKS​
    7·1 answer
  • A new PKI is being built at a company, but the network administrator has concerns about spikes of traffic occurring twice a day
    5·1 answer
  • 20 points!!
    7·1 answer
  • You are supposed to do a report on something that interests you. You decided to do a report on dogs. As you research, you take n
    14·1 answer
  • Which type of work would be a good candidate for improvement through automation?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!