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
What best describes "broadband access"?
Andre45 [30]

Answer:

The Correct option is : d. BROADBAND ACCESS enable users to connect to a high speed networks

Explanation:

As the names implies BROADBAND ACCESS can be defined as a technology that enables users to have the access to fast and high speed internet connection when browsing, streaming or downloading reason been that BROADBAND ACCESS is more faster and quicker which inturn enables the user to do a lot more on the internet which is why BROADBAND ACCESS is often refer or known as a high and fast speed Internet access connection.

5 0
3 years ago
I dunno what to write my memo thing about ⁻³⁻
Alex73 [517]

Answer:

Wdym? I could help u

Explanation:

5 0
3 years ago
Read 2 more answers
I need Help!!<br> 4. Explain the importance of including negative space as part of a design.
vova2212 [387]
Negative space is the space between, within and surrounding an object in an image. The positive space is the focus of the image, the object itself, but the negative space is just as important. It shares edges with the positive space, defining the outline of the object and creating proportion
5 0
3 years ago
Need help coding this it uses input and I need to use the words good and morning
Masja [62]

Answer:

x = input ("Enter a word: ")

y = input ("Enter a word: ")

print ( x, " ", y)

Explanation:

This is the simplest way to write it using Python.

6 0
2 years ago
Read one positive integer n. Then create an n X n two-dimensional array and write the code that stores integers from 1 to n2 as
marysya [2.9K]

Answer:

The program in Java is as follows:

import java.util.*;

public class Main{

public static void main(String[] args) {

    int n;

    Scanner input = new Scanner(System.in);

 System.out.print("Size of array: ");

 n = input.nextInt();

 int count = 1;

 int[][] arr = new int[n][n];

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

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

         arr[i][j] = count;

         count++;      }  }

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

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

         System.out.printf(arr[i][j]+" ");      }

     System.out.println();  } }}

Explanation:

This declares the size of the array

    int n;

    Scanner input = new Scanner(System.in);

This prompts the user for size of array

 System.out.print("Size of array: ");

This gets input for size of array

 n = input.nextInt();

This initializes the array element to 1

 int count = 1;

This creates a 2d array

 int[][] arr = new int[n][n];

This iterates through the rows

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

This iterates through the columns

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

This populates the array

         arr[i][j] = count;

         count++;      }  }

The following nested loop prints the array elements

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

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

         System.out.printf(arr[i][j]+" ");      }

     System.out.println();  } }}

8 0
2 years ago
Other questions:
  • Technology progresses so new needs can be satisfied.<br><br> A. true<br><br> B. false
    12·2 answers
  • Which ipv6 static route would serve as a backup route to a dynamic route learned through ospf?
    12·1 answer
  • 1. The future of 2D animation does not include hand-drawing. (1 point)
    13·1 answer
  • Your boss wants to utilize some sort of cloud storage for his files so that all of his
    10·2 answers
  • Choose the statement that describes an advantage of paying a bill through the mail with a check.
    6·2 answers
  • Oiê gentee, bom dia O que você entende por cultura digital ??
    12·1 answer
  • What is a header row?
    8·1 answer
  • Part of metacognition involves making a plan to address <br> .
    9·2 answers
  • My game is telling me to "Press any key." Where is the "any" key?????
    13·1 answer
  • Do you need a separate password for each slack channel
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!