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
MrRa [10]
1 year ago
9

Complete function PrintPopcornTime(), with int parameter bagOunces, and void return type. If bagOunces is less than 3, print "To

o small". If greater than 10, print "Too large". Otherwise, compute and print 6 * bagOunces followed by " seconds". End with a newline. Example output for ounces = 7:42 seconds#include void PrintPopcornTime(int bagOunces) {}int main(void) {int userOunces;scanf("%d", &userOunces);PrintPopcornTime(userOunces);return 0;}2. Write a function PrintShampooInstructions(), with int parameter numCycles, and void return type. If numCycles is less than 1, print "Too few.". If more than 4, print "Too many.". Else, print "N: Lather and rinse." numCycles times, where N is the cycle number, followed by "Done.". End with a newline. Example output with input 2:1: Lather and rinse.2: Lather and rinse.Done. Hint: Declare and use a loop variable.#include /* Your solution goes here */int main(void) {int userCycles;scanf("%d", &userCycles);PrintShampooInstructions(userCycles);return 0;}

Computers and Technology
1 answer:
SVETLANKA909090 [29]1 year ago
6 0

Answer:

<h2>Function 1:</h2>

#include <stdio.h> //for using input output functions

// start of the function PrintPopcornTime body having integer variable //bagOunces as parameter

void PrintPopcornTime(int bagOunces){

if (bagOunces < 3){ //if value of bagOunces is less than 3

 printf("Too small"); //displays Too small message in output

 printf("\n"); } //prints a new line

//the following else if part will execute when the above IF condition evaluates to //false and the value of bagOunces is greater than 10

else if (bagOunces > 10){

    printf("Too large"); //displays the message:  Too large in output

    printf("\n"); //prints a new line }

/*the following else  part will execute when the above If and else if conditions evaluate to false and the value of bagOunces is neither less than 3 nor greater than 10 */

else {

/* The following three commented statements can be used to store the value of bagOunces * 6 into result variable and then print statement to print the value of result. The other option is to use one print statement printf("%d",bagOunces * 6) instead */

    //int result;

    //result = bagOunces * 6;

    //printf("%d",result);

 printf("%d",bagOunces * 6);  /multiplies value of bagOunces  to 6

 printf(" seconds");

// seconds is followed with the value of bagOunces * 6

 printf("\n"); }} //prints a new line

int main(){ //start of main() function body

int userOunces; //declares integer variable userOunces

scanf("%d", &userOunces); //reads input value of userOunces

PrintPopcornTime(userOunces);

//calls PrintPopcornTime function passing the value in userOunces

return 0; }

Explanation:

<h2>Function 2:  </h2>

#include <stdio.h> //header file to use input output functions

// start of the function PrintShampooInstructions body having integer variable numCycles as parameter

void PrintShampooInstructions(int numCycles){

if(numCycles < 1){

//if conditions checks value of numCycles is less than 1 or not

printf("Too few."); //prints Too few in output if the above condition is true

printf("\n"); } //prints a new line

//else if part is executed when the if condition is false and else if  checks //value of numCycles is greater than 4 or not

else if(numCycles > 4){

//prints Too many in output if the above condition is true

printf("Too many.");

printf("\n"); } //prints a new line

//else part is executed when the if and else if conditions are false

else{

//prints "N: Lather and rinse." numCycles times, where N is the cycle //number, followed by Done

for(int N = 1; N <= numCycles; N++){

printf("%d",N);

printf(": Lather and rinse. \n");}

printf("Done.");

printf("\n");} }

int main() //start of the main() function body

{    int userCycles; //declares integer variable userCycles

   scanf("%d", &userCycles); //reads the input value into userCycles

   PrintShampooInstructions(userCycles);

//calls PrintShampooInstructions function passing the value in userCycles

   return 0;}

I will explain the for loop used in PrintShampooInstructions() function. The loop has a variableN  which is initialized to 1. The loop checks if the value of N is less than or equal to the value of numCycles. Lets say the value of numCycles = 2. So the condition evaluates to true as N<numCycles  which means 1<2. So the program control enters the body of loop. The loop body has following statements. printf("%d",N); prints the value of N followed by

printf(": Lather and rinse. \n"); which is followed by printf("Done.");

So at first iteration:

printf("%d",N); prints 1 as the value of N is 1

printf(": Lather and rinse. \n");  prints : Lather and rinse and prints a new line \n.

As a whole this line is printed on the screen:

1: Lather and rinse.

Then the value of N is incremented by 1. So N becomes 2 i.e. N = 2.

Now at second iteration:

The loop checks if the value of N is less than or equal to the value of numCycles. We know that the value of numCycles = 2. So the condition evaluates to true as N<numCycles  which means 2=2. So the program control enters the body of loop.

printf("Done."); prints Done after the above two lines.

printf("%d",N); prints 2 as the value of N is 2

printf(": Lather and rinse. \n");  prints : Lather and rinse and prints a new line \n.

As a whole this line is printed on the screen:

2: Lather and rinse.

Then the value of N is incremented by 1. So N becomes 2 i.e. N = 3.

The loop again checks if the value of N is less than or equal to the value of numCycles. We know that the value of numCycles = 2. So the condition evaluates to false as N<numCycles  which means 3>2. So the loop breaks.

Now the next statement is:

printf("Done."); which prints Done on the screen.

So as a whole the following output is displayed on the screen:

1: Lather and rinse.

2: Lather and rinse.

Done.

The programs along with their outputs are attached.

You might be interested in
Ryan has made a presentation of ten slides, which he wants to display in sequence after a specific time interval. Which element
alukav5142 [94]

Answer:

Slide transition.

Explanation:

PowerPoint application can be defined as a software application or program designed and developed by Microsoft, to avail users the ability to create various slides containing textual and multimedia informations that can be used during a presentation.

Some of the features available on Microsoft PowerPoint are narrations, transition effects, custom slideshows, animation effects, formatting options etc.

Basically, the views that are available on the Microsoft PowerPoint application includes;

1. Slide Sorter.

2. Notes Page.

3. Reading Pane.

4. Presenter view.

In this scenario, Ryan has made a presentation of ten slides, which he wants to display in sequence after a specific time interval.

Using slide transition in the presentation software, Ryan can make the slides appear, one after the other, after a specific time interval.

Slide transition is an inbuilt feature of a presentation software that automatically changes the slides at regular intervals.

3 0
1 year ago
PLEASE HELP PROGRAMMING WILL GIVE BRAINLIEST
JulijaS [17]
The fourth choice is correct.
5 0
2 years ago
Modern operating system decouple a process address space from the machine's physical memory. list two advantages of this design.
likoan [24]

The two advantages of modern operating systems is that it has the capacity in helping programs to be loaded faster compared to other older versions and it also has the ability of having to run programs that are large enough in which is in the main memory even if it is smaller compared to the size of its program.

4 0
2 years ago
What protocol communicates data between routers representing the edges of autonomous systems?Distance-vectorLink stateInterior g
Nata [24]

Explanation:

Exterior gateway protocol are the routing protocols that are used on the internet for exchanging routing information among the autonomous system. These autonomous systems can be gateway protocol, vector routing protocol.

8 0
1 year ago
Replace the underlines with the words in parentheses that follow: the ____ solves the ____ of a ____ by expressing an ____ in a
adell [148]

The programmer solves the problems of a user by expressing an algorithm in a programming language to make a program that can run on a computer.

5 0
2 years ago
Other questions:
  • James is an employee at the packaging unit of a chocolate factory that has come up with a new concept of packaging and marketing
    11·2 answers
  • Fill in the blank; "As well as their traditional role of computing data, computers are also extensively used for..."
    14·1 answer
  • Which Internet of Things (IoT) challenge involves the difficulty of developing and implementing protocols that allow devices to
    11·1 answer
  • With respect to the general classes of computers, a ________ is the most expensive and most powerful kind of computer, which is
    7·1 answer
  • Ld' is the instruction with the longest latency on the CPU from Section 4.4 (in RISC-V text). If we modified ld and sd so that t
    15·1 answer
  • array of String objects, words, has been properly declared and initialized. Each element of words contains a String consisting o
    11·1 answer
  • Suppose two threads execute the following C code concurrently, accessing shared variables a, b, and c: Initialization int a = 4;
    15·1 answer
  • A program is divided into 3 blocks that are being compiled on 3 parallel computers. Each block takes an Exponential amount of ti
    6·1 answer
  • Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space. Example
    6·1 answer
  • 3. Write a program to find the area of a triangle using functions. a. Write a function getData() for user to input the length an
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!