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
Llana [10]
2 years ago
3

Write a program that calls a function calculateSum to calculate the sum from 0 to N integers. The function calculateSum has one

parameter N of type integer and returns an integer which represents the sum from 0 to N, inclusive. Write another function calculateAverage that calculates an average. This function will have two parameters: the sum and the number of items. It returns the average (of type float). The main function should be responsible for all inputs and outputs. Your functions will only calculate and return the values and NOT print anything. N is provided by the user; user input must be asked for repeatedly until a non-negative integer is provided.
Computers and Technology
1 answer:
r-ruslan [8.4K]2 years ago
4 0

Answer:

#include <iostream>

using namespace std;

int calculateSum(int n){

  int sum = 0;

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

      sum += i;

  }

  return sum;

}

float calculateAverage(int sum, int n){

  return 1.0*sum/n;

}

int main()

{

  int n;

  cout<<"Enter n: ";

  cin>>n;

  int sum = calculateSum(n);

  float avg = calculateAverage(sum,n);

  cout<<"Sum = "<<sum<<endl;

  cout<<"Average = "<<avg<<endl;

  return 0;

}

Explanation:

You might be interested in
A(n) ________ system collects data from various key business processes and stores the data in a single comprehensive data reposi
Anni [7]
Management information
4 0
2 years ago
In the game Singularity, broken objects can be restored to their original condition by reversing time. This is an example of whi
Zolol [24]

Solution:

In the game Singularity, broken objects can be restored to their original condition by reversing time. This is an example of which time element of player adjustment.

Thus the required answer is player adjusted.

6 0
2 years ago
Read 2 more answers
When performing actions between your computer and one that is infected with a virus, which of the following offers NO risk of yo
DochEvi [55]
What are the options?
3 0
2 years ago
Read 2 more answers
Which statements describe best practices for aligning text? check all that apply
kiruha [24]

Answer: *use the last column for text with multiple lines.

*use an indent marker to indent the first line of a paragraph.

*use a table if text in multiple columns have multiple lines.

Explanation:

5 0
2 years ago
Read 2 more answers
The ________ program displays graphics and loading screens during the boot process.
Minchanka [31]
Booting would be complete if the normal, runtime environment has been achieved. A boot loader is a program that loads operating system for the computer after the completion of power on tests. The boot manager is a program that displays graphics and loading screens during the boot process.
3 0
2 years ago
Other questions:
  • Which selections are possible for controlling the start time of audio playback? Check all that apply. Automatic Rewind when done
    10·1 answer
  • Write an if-else statement that prints "Goodbye" if userString is "Quit", else prints "Hello". End with newline.
    11·2 answers
  • Match the following technologies with their applications.
    9·1 answer
  • Jane is designing a print brochure for a retail company. She’s having trouble deciding on the page margin. Which best practice w
    13·2 answers
  • Write a destructor for the CarCounter class that outputs the following. End with newline.
    9·1 answer
  • What email server does Global Enterprises use?
    7·1 answer
  • ) A byte is used to represent a single character in the computer ______<br> true or false?
    14·2 answers
  • A collection of technologies that allow publishing of search results in a format suitable for syndication and aggregation. It is
    5·1 answer
  • Draw a flowchart and write the algorithm to find even number between 1 to 50​
    7·1 answer
  • The height of a small rocket y can be calculated as a function of time after blastoff with the following piecewise function: y 5
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!