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
PLEASE HELP ASAP!! Timed test!!
maks197457 [2]

Answer:

d i think

Explanation:

6 0
2 years ago
The list method reverse reverses the elements in the list. Define a function named reverse that reverses the elements in its lis
Alisiya [41]

Answer:

public class Reverse {

  1.    public static void reverseList(int list [], int n)
  2.    {
  3.        int[] reversedList = new int[n];
  4.        int k = n;
  5.        for (int i = 0; i < n; i++) {
  6.            reversedList[k - 1] = list[i];
  7.            k = k - 1;
  8.        }
  9.        //printing the reversed list
  10.        System.out.println("The Reversed list \n");
  11.        for (int j = 0; j < n; j++) {
  12.            System.out.println(reversedList[j]);
  13.        }
  14.    }

Explanation:

Using Java, An array is implemented to hold a list of items

A method reverseList() is created to accept an array as parameter and using a for statement reverses the elements of the array and prints each element of the list

See below a complete code with a main method that calls this method

<em>public class Reverse {</em>

<em>    public static void main(String[] args) {</em>

<em>        int [] arr = {10, 20, 30, 40, 50};</em>

<em>        reverseList(arr, arr.length);</em>

<em>    }</em>

<em>    public static void reverseList(int list [], int n)</em>

<em>    {</em>

<em>        int[] reversedList = new int[n];</em>

<em>        int k = n;</em>

<em>        for (int i = 0; i < n; i++) {</em>

<em>            reversedList[k - 1] = list[i];</em>

<em>            k = k - 1;</em>

<em>        }</em>

<em>        //printing the reversed list</em>

<em>        System.out.println("The Reversed list \n");</em>

<em>        for (int j = 0; j < n; j++) {</em>

<em>            System.out.println(reversedList[j]);</em>

<em>        }</em>

<em>    }</em>

<em>}</em>

7 0
3 years ago
What was the first video game ever invented
Sever21 [200]

Answer:

Pong

Explanation:

In 1958, a physicist created a tennis game in which he found the very first video game.

3 0
3 years ago
Read 2 more answers
A typical analog cell phone has a frequency of 850 mhz; a digital phone a frequency of 1950 mhz. compared to the signal from an
Zepler [3.9K]
A higher frequency than the analog cell phone.
5 0
3 years ago
Need help fast this is do a 4
Stells [14]

Answer:

I believe the answer is B.

8 0
3 years ago
Other questions:
  • In​ today's global​ environment, everything and everyone are digitally connected to everything and everyone else. The term used
    6·1 answer
  • Instructions:Type the correct answer in the box. Spell all words correctly.
    14·2 answers
  • An electronic braille embosser that translates text from a braille keyboard to a printer:
    10·1 answer
  • Henry went to an IT software company for an interview he was offered a position in lower level management which positions could
    11·1 answer
  • Select the correct answer.
    13·1 answer
  • You are tasked with accumulating survey data on a web page and are responsible for it being free from dirty data once you close
    11·1 answer
  • To answer the research question "How am I going to find the information I need on the tople?" the best thing Georgia should
    15·1 answer
  • How do you invite someone to a conversation on brainly
    14·1 answer
  • Overview In this assignment, you will gain more practice with designing a program. Specifically, you will create pseudocode for
    7·1 answer
  • A software giant is enabling a city with smart parking, using real-time information captured by sensors on the vehicle and senso
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!