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
Read the following example cover letter:
enot [183]

Answer:

All should be added.

Explanation:

All of these are important to your cover letter to make it seem professional.

Hope this helped

3 0
3 years ago
Read 2 more answers
You have been employed as a technical consultant to a computer shop chain. You are given the task of creating a short consumer b
brilliants [131]

Answer:

The five factors to consider when trying to choose between a Solid State Drive, a Hard Disk Drive and, an External Hard Disk Drive are:

  1. Read/Write Speed
  2. Weight
  3. Power Consumption
  4. Cost
  5. Storage Capacity

  • Solid State Drives (SSDs) are typically lighter in weight, faster and do not consume much power.
  • Hard Disk Drives are relatively cheaper than SSDs. They also come with higher storage capacities but are more power-hungry and slower because they rely on mechanical/moving parts to read and write data.
  • External HDDs are the cheapest of the three. They are not internal which is a major drawback given the additional weight. However, they come with gargantuan storage capacities that make you want to rethink having one. Besides, unlike SSDs, you can easily get them in computer accessories shops offline or online.

Cheers!

3 0
3 years ago
How often should you typically monitor your checking account? Yearly Daily Every three months Monthly
Maslowich
I’d say monthly. It probably wouldn’t kill you to do it every three months though.
7 0
3 years ago
Read 2 more answers
Which of these are correctly formatted Python dictionaries? Check all that apply. dict = {‘Name’: ‘Matthew’, ‘Age’: 14, ‘School’
Advocard [28]

Answer:

A. dict = {‘Name’: ‘Matthew’, ‘Age’: 14, ‘School’: ‘ABC School’}

Explanation:

Since <em>python does not use type when declaring a variable</em>, you must make sure you make your variables correctly or else it won't compile correctly. Lists use braces[]; Strings use quotes, "" or ''; Integers are just declared with a number(s); Dictionaries use brackets{} and inside are <u>attributes of something</u>. For instance, you can use dictionaries to describe ages, {'"Bryan": 6, "Alex": 13, etc.} <u>Sort of like a json file</u>. Dictionaries also tend to use <u>uppercase letters</u> when describing something. The only answer that has all the attributes correct is A. dict = {‘Name’: ‘Matthew’, ‘Age’: 14, ‘School’: ‘ABC School’}

hope i helped :D

7 0
3 years ago
Read 2 more answers
One subtask in the game is to roll the dice. explain why is roll the dice an abstraction.
LUCKY_DIMON [66]

Answer:

A game is built from a combination of sub-tasks in order to provide the best experience to the user and make sure that the interface is comprises of only the results of the ongoing sub-tasks to provide a higher degree of data abstraction.

Data abstraction refers to the process of representing the essential information without including the background details. Rolling a dice is preferred to be a sub-task so that the user only gets to know about the result of the roll and does not have to wait for or anticipate the result. Moreover, a game may consist of n number of sub-tasks so it is not a good idea to include them in the main framework and are preferred to be abstracted.

4 0
2 years ago
Other questions:
  • I need some cool things to do with windows command prompt.
    13·1 answer
  • ________ are viruses that masquerade as useful programs or files. hydras spyware programs worms adware programs trojan horses
    6·1 answer
  • PLS HELP!!
    13·1 answer
  • What does intergrated organization mean
    15·1 answer
  • Linux is: Select one: a. primarily concerned with the tasks of end users. b. designed for specific machines and specific micropr
    10·1 answer
  • The term computer ________ is used to describe someone who is familiar enough with computers to understand their capabilities an
    12·1 answer
  • Explain the components of Information System?​
    13·1 answer
  • Coment on this if your user starts with dida
    5·1 answer
  • I re-made the human version of Daddy Dearest from Friday Night Funkin
    14·2 answers
  • Why is color important for all objects drawn ?​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!