answer.
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
kupik
6 days 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:
Natasha_Volkova [946]6 days ago
4 0

Answer:

The C++ function definition for printAttitude can be seen 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:

It is notable that this method takes an int parameter.

Since it yields no value, it has a void return type.

The console displays messages based on the integer parameter, n, using a switch statement.

Output conditions are specified in different cases.

The default case takes care of values where no output is needed.

Each case concludes with a break statement to end the execution of the program.

This function can be utilized within a program as illustrated.

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 called with the user-input as a parameter.

3. If a user enters 11, which does not match any of the case values, the default case is executed, which does nothing and the break statement runs.

4. Thus, nothing is displayed for the input of 11.

5. When the user inputs 3, the corresponding case block is executed since it matches the case values.

6. The program produces the following output when the user inputs 3.

OUTPUT

Enter any number: 3

agree

The program concludes with a return statement.

You might be interested in
The Pentium 4 Prescott processor, released in 2004, had a clock rate of 3.6 GHz and voltage of 1.25 V. Assume that, on average,
Natasha_Volkova [946]

Answer:

1. The capacitive load for the Pentium 4 Prescott processor is 32 nF. For the Core i5 Ivy processor, it is 29.05 nF.

2. The static power makes up 10% of the total power dissipated for the Pentium 4 Prescott processor. The static to dynamic power ratio is 0.11.

For the Core i5 Ivy Bridge processor, the static power percentage is 42.86%. The ratio of static to dynamic power stands at 0.75.

3. The voltage reduction for the Pentium 4 Prescott processor equals a decrease of 5.9 %.

The Core i5 Ivy Bridge processor sees a 9.8 % reduction in voltage.

Explanation:

1. Recognizing dynamic power, P as approximately 1/2 CV²f, where C is the transistor's capacitive load, v denotes voltage, and f is frequency.

Thus, C is found using the formula C ≈ 2P/V²f.

For the Pentium 4 Prescott processor, with V₁ = 1.25 V, f₁ = 3.6 GHz, and P₁ = 90 W, we denote its capacitive load as C₁. Thus, we find C₁ ≈ 2P/V²f = 2 × 90 W/(1.25 V)² × 3.6 × 10⁹ Hz = 3.2 × 10⁻⁸ F = 32 × 10⁻⁹ F = 32 nF.

For the Core i5 Ivy Bridge processor, with V = 0.9 V, f = 3.4 GHz, and P = 40 W, we define C₂ as its load. Therefore, C₂ ≈ 2P/V²f = 2 × 40 W/(0.9 V)² × 3.4 × 10⁹ Hz = 2.905 × 10⁻⁸ F = 29.05 × 10⁻⁹ F = 29.05 nF.

2. The summation of total power is derived from static plus dynamic power.

For Pentium 4 Prescott, static power adds to 10 W and dynamic power is 90 W. Hence, the overall power, P = 10 W + 90 W = 100 W.

The fraction of this total attributed to static power is calculated as static power over total power multiplied by 100, thus static power/total power × 100 = 10/100 × 100 = 10%.

The ratio of static to dynamic power equals static power over dynamic power = 10/90 = 0.11.

For the Core i5 Ivy Bridge, static power figures at 30 W, and dynamic power at 40 W, meaning the total power becomes P = 30 W + 40 W = 70 W.

The portion of the total power that is static is computed as static power/total power × 100 = 30/70 × 100 = 42.86%.

That ratio of static to dynamic stands at static power/dynamic power = 30/40 = 0.75.

3. The total power comprises static and dynamic contributions and resulting leakage current arises from static power. We understand that P = IV, hence leakage current, I = P/V.

With an intended total power reduction of 10%, we have P₂ = (1 - 0.1)P₁ = 0.9P₁, where P₁ is the initial dissipated power before the 10% decrement and P₂ represents the new dissipated power.

Hence, new total dissipated power P₂ = new static power I₂V₂ + new dynamic power 1/2C₂V₂²f₂ = 0.9P₁.

For the Pentium 4 Prescott with P₂ = I₂V₂ + 1/2C₂V₂²f₂ = 0.9P₁, given I₂ as leakage current which equals static power/voltage = 10 W/1.25 V = 8 A (since leakage remains constant), we determine

8 A × V₂ + 1/2 × 32 × 10⁻⁹ F × V₂² × 3.6 × 10⁹ Hz = 0.9 × 100.

This simplifies to 8V₂ + 57.6V₂² = 90, leading to the quadratic equation.

57.6V₂² + 8V₂ - 90 = 0, from which applying the quadratic formula yields

V₂ = \frac{-8 +/- \sqrt{8^{2} -4X57.6 X -90} }{2X57.6} = \frac{-8 +/- \sqrt{64 + 20736} }{115.2} = \frac{-8 +/- \sqrt{20800} }{115.2}\\=\frac{-8 +/- 144.222}{115.2}\\.

Choosing the positive result, V₂ arrives at 1.18 V. The calculated reduction percentage is given by (new voltage - old voltage)/new voltage × 100% = (1.18 - 1.25)/1.18 × 100% = -0.07/1.18 × 100% = -5.9% with a 5.9% drop from 1.25V.

For the Core i5 Ivy Bridge processor, it follows that P₂ = I₂V₂ + 1/2C₂V₂²f₂ = 0.9P₁. With I₂ as leakage current equaling static power/voltage = 30 W/0.9 V = 33.33 A (again, leakage remains constant), we next evaluate

33.33 A × V₂ + 1/2 × 29.05 × 10⁻⁹ F × V₂² × 3.4 × 10⁹ Hz = 0.9 × 70.

This resolves to 33.33V₂ + 49.385V₂² = 63. Thus, it simplifies to the quadratic equation

49.385V₂² + 33.33V₂ - 63 = 0, whereby employing the quadratic formula lets us find

V₂ = \frac{-49.385 +/- \sqrt{49.385^{2} -4X33.33 X -63} }{2X33.33} = \frac{-49.385 +/- \sqrt{2438.8782 + 8399.916} }{66.66} = \frac{-49.385 +/- \sqrt{10838.794} }{66.66}\\=\frac{-49.385 +/- 104.110}{66.66}\\.

Choosing the positive answer provides a new voltage of 0.82 V. The percentage reduction computes as (new voltage - old voltage)/new voltage × 100% = (0.82 - 0.9)/0.82 × 100% = -0.08/0.82 × 100% = -9.8% with a 9.8% decrease from 0.9V.

6 0
1 month ago
Write a program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename
amid [867]

This code is in Python. I'm not certain what programming language you need.

Refer to the image:

7 0
1 month ago
Read 2 more answers
Find true or false. A hacker is hacking software with access in sensitive information from your computer​
Harlamova29_29 [950]
IT'S CORRECT!! I LOOKED IT UP
7 0
22 days ago
A 1.17 g sample of an alkane hydrocarbon gas occupies a volume of 674 mL at 28°C and 741 mmHg. Alkanes are known to have the gen
Natasha_Volkova [946]

Answer:

C3H8

Explanation:

Step 1:

Relevant details from the question are noted below:

Mass of the alkane is 1.17g

Volume (V) = 674 mL

Temperature (T) = 28°C

Pressure (P) = 741 mmHg.

Gas constant (R) = 0.08206 atm.L/Kmol

Step 2:

Convert to the appropriate units.

For Volume:

1000mL = 1L

So, 674mL = 674/1000 = 0.674L

For Temperature:

Temperature in Kelvin = Temperature in Celsius + 273

Temperature in Celsius = 28°C

Temperature in Kelvin = 28°C + 273 = 301K

For Pressure:

760mmHg = 1atm

So, 741 mmHg = 741/760 = 0.975atm

Step 3:

Calculate the moles of the alkane.

The moles of the alkane can be found using the ideal gas equation, presented below:

Volume (V) = 0.674L

Temperature (T) = 301K

Pressure (P) = 0.975atm

Gas constant (R) = 0.08206 atm.L/Kmol

Number of moles (n) =?

PV = nRT

n = PV /RT

n = (0.975 x 0.674)/(0.08206x301)

n = 0.0266 moles

Step 4:

Calculate the alkane’s molar mass.

Mass of alkane = 1.17g

Number of moles = 0.0266moles

Molar Mass =?

Number of moles = Mass/Molar Mass

Molar Mass = Mass/Number of moles

Molar Mass of alkane = 1.17/0.0266 = 44g/mol

Step 5:

Determine the molecular formula of the alkane.

This is based on:

The general formula for alkanes is CnH2n+2

To find the molecular formula, we start with n = 1, 2, 3, etc., until we find the molar mass of 44.

When n = 1

CnH2n+2 = CH4 = 12 + (4x1) = 16g/mol

When n = 2

CnH2n+2 = C2H6 = (12x2) + (6x1) = 30g/mol

When n = 3

CnH2n+2 = C3H8 = (12x3) + (8x1) = 44g/mol

It can be observed that for n equal to 3, the molar mass is 44g/mol.

Thus, the molecular formula of the alkane is C3H8.

7 0
1 month ago
FOREACH, EXPLODE and MAIL are examples of crazy functions.
zubka84 [1007]
The selected response is B
4 0
1 month ago
Other questions:
  • Implement the function couple, which takes in two lists and returns a list that contains lists with i-th elements of two sequenc
    8·1 answer
  • A have a string, called "joshs_diary", that is huge (there was a lot of drama in middle school). But I don't want every one to k
    5·1 answer
  • Until 2015, each new Roblox user automatically had one friend. What was he called?
    12·2 answers
  • Tag groups can be nested up to ____ levels deep, with up to _______ tag subgroups under a single parent.
    14·1 answer
  • When a CPU executes instructions as it converts input into output, it does so with
    12·1 answer
  • An Internet user has a need to send private data to another user. Which of the following provides the most security when transmi
    14·2 answers
  • More Loops: All versions of foods.py in this section have avoided using for loops when printing to save space. Choose a version
    13·1 answer
  • Describe a situation involving making a copy of a computer program or an entertainment file of some sort for which you think it
    7·1 answer
  • Assign to avg_owls the average owls per zoo. Print avg_owls as an integer. Sample output for inputs: 1 2 4 3
    7·1 answer
  • Flowgorithm, Design a program that prompts the user to enter a number within the range of 1 through 10. The program should displ
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!