Write the definition of a function printAttitude, which has an int parameter and returns nothing. The function prints a message to standard output depending on the value of its parameter. If the parameter equals 1, the function prints disagree If the parameter equals 2, the function prints no opinion If the parameter equals 3, the function prints agree In the case of other values, the function does nothing. Each message is printed on a line by itself.

Respuesta :

Limosa

Answer:

Following are the program in the C++ Programming Language.

//define function

void printAttitude(int input)

{

//set the switch statement

switch(input)

{

//check the condition that argument is 1

case 1:

//print message then, break the statement

cout<<"disagree";

break;

//check the condition that the argument contain 2

case 2:

//print message then, break the statement

cout<<"no opinion";

break;

//check the condition that the argument contain 3

case 3:

//print message then, break the statement

cout<<"agree";

break;

}

}

Explanation:

Following are the description of the program:

  • Firstly, set void type function that is 'printAttitude()' with integer data type argument that is 'input'.
  • Then, set the switch statement that checks the value of the variable 'input', if the value of the variable 'input' is 1 then, print the message 'disagree' then, if the value is 2 it prints 'no opinion' and if the value is 3 then, it prints 'agree'.
ACCESS MORE