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
Svetradugi [14.3K]
3 years ago
14

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.
Computers and Technology
1 answer:
Oksana_A [137]3 years ago
4 0

Answer:

The function definition, in cpp, for the function printAttitude is given below.

void printAttitude(int n)

{

switch(n)

{

case 1: cout<<"disagree"<<endl; break;

case 2: cout<<"no opinion"<<endl; break;

case 3: cout<<"agree"<<endl; break;

default: break;

}

}

Explanation:

As seen, the method takes an integer parameter.

The method does not returns any value hence, return type is void.

The message is displayed to the console using switch statement which executes on the integer parameter, n.

The values for which output needs to be displayed are taken in cases.

The values for which no output needs to be displayed, is taken in default case.

Every case ends with break statement so that the program execution can be terminated.

This method can be used inside a program as shown.  

PROGRAM

#include <iostream>

using namespace std;

void printAttitude(int n)

{

switch(n)

{

case 1: cout<<"disagree"<<endl; break;

case 2: cout<<"no opinion"<<endl; break;

case 3: cout<<"agree"<<endl; break;

default: break;

}

}

int main() {

// variables to hold respective value

int n;

// user input taken for n

cout<<"Enter any number: ";

cin>>n;

// calling the function taking integer parameter  

printAttitude(n);

return 0;

}

OUTPUT

Enter any number: 11

1. The user input is taken for the integer parameter.

2. Inside main(), the method, printAttitude(), is then called and the user input is passed as a parameter.

3. Since the user entered value is 11 which does not satisfies any of the values in the cases, the default case is entered which does nothing and executes the break statement.

4. Hence, the program displays nothing for the value of 11.

5. When the user enters value 3, the case statement is executed since 3 satisfies one of the case values.

6. The program output for the user input of 3 is as shown below.

OUTPUT

Enter any number: 3

agree

The program ends with return statement.

You might be interested in
Which degree is usually required for librarians who manage library holdings and assist patrons with book, periodical, and comput
IRISSAK [1]

i think C

help from Russia


6 0
3 years ago
Read 2 more answers
In what four ways do we commonly respond?
Gnoma [55]

Answer:

A

Explanation:

4 0
3 years ago
Consider the following code segment, where num is a properly declared and initialized integer variable. The following code segme
seropon [69]

Answer:

10 or 22 or 15 or 40

Explanation:

In the second for loop[for (int k = 1; k < arr[0].length; k++)], k starts from 1 instead of zero. That means that it doesn't read the first value of every row when finding num.

So if num was any of the above values, the program wouldn't work. I had the same question, and the answer for mine was 15.

3 0
3 years ago
A network technician needs to set up two public facing web servers and watns to ensure that if they are compromised the intruder
Taya2010 [7]

Answer:

D. Place them in the demilitarized zone.

Explanation:

Demilitarized zone(DMZ) is a logical or physical sub network that contains and gives exposure to an organization's external-facing services to an not trust worthy network, basically a larger network like Internet. It's purpose is to add an extra layer of security in an organization's LAN(local area network).So we conclude that DMZ is best way so that intruder cannot access the intranet.

4 0
3 years ago
g Organization: inputs --&gt; processes --&gt;outputs. Which one of the following correctly describes a production system? Hint:
Sholpan [36]

Answer:

Furniture manufacturer: wood --> sanding --> chair

Explanation:

Operations Management can defined as the process which transforms the inputs of an organization into final goods (or services), this is usually achievable through a set of defined, controlled and repeatable policies.

Furniture manufacturer: Wood-> Sanding-> Chair is the correct option as Wood is an input. Sanding is a set of process and Chair is the required output. The other options do not follow these set of defined policies.

8 0
3 years ago
Other questions:
  • What observational data required the revision of the early geocentric model?
    5·1 answer
  • He following is a string of ASCII characters whose bit patterns have been converted into hexadecimal for compactness: 4A EF 68 6
    12·1 answer
  • Which osi layer is responsible for combining bits into bytes and bytes into frames?
    8·1 answer
  • What is a lease? AA contract outlining the terms of a mortgage. BA contract outlining the terms under which a landlord agrees to
    15·1 answer
  • Indicate if the following statements are True or False. Statement Circle one Internet Service Providers (ISPs) are proprietary n
    13·1 answer
  • The ________ file system supports a maximum file size of 2gb
    12·1 answer
  • Plz help meeeeee QUICKLY!!! WORTH 15 POINTS!
    15·1 answer
  • Test if the word mold is stored in the variable word. Computer science.
    9·1 answer
  • Write a program that reads in ten numbers from the user and displays the distinct numbers. If a number entered by the user appea
    13·1 answer
  • Create a class called StockTester that has the following fucntionality. a. Create a main method with an ArrayList named dataStoc
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!