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
Llana [10]
4 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]4 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
Which relationship is possible when two tables share the same primary key?
klasskru [66]

Answer:

Many-to-one

Explanation:

Many-to-one relationships is possible when two tables share the same primary key it is because one entity contains values that refer to another entity that has unique values. It often enforced by primary key relationships, and the relationships typically are between fact and dimension tables and between levels in a hierarchy.

6 0
3 years ago
Favorite friends character and why GO!
Masteriza [31]
Rachel Def i really don’t know just cause
7 0
3 years ago
Read 2 more answers
ENG103 DISCUSSION BOARD 6
amm1812
The proper citation for your course of study -computer related- is APA (American Psychological Association)  format. This citation format allows us to state the publication date, title , and authors in an organized and short fashion. All scholarly reports that are technology or psychology based, should be cited in APA format. 

<span>I know this because it is the format I use for all of my college courses which are all Computer/Technology related. </span>
3 0
3 years ago
Code the function definition for aNonclassFunction, picking up co. aNonclassFunction has no return value.
enot [183]

Answer:

b)void aNonclassFunction (Banana co);

Explanation:

In the function definition you have to pass the tell the function which type of argument it is taking.In our case we are taking a variable co of Banana type passing it to the function named aNonclassFunction having no return type.

So the definition will be like this.

void aNonclassFunction (Banana co);

6 0
3 years ago
Use the Wrap Text icon to _____. modify which graphic appears in the front of layered images modify the picture effects change t
sergey [27]

I believe it's change the way text is wrapped around an object.

3 0
3 years ago
Read 2 more answers
Other questions:
  • You can use the_______key if your cursor is at the end of the word. Use the______key if you place the cursor on the left side of
    11·1 answer
  • Your organization issues devices to employees. These devices generate one-time passwords every 60 seconds. A server hosted withi
    15·1 answer
  • Which of these items will least likely increase pressure in the evaporative emission control system?
    9·1 answer
  • Stella is surfing the Internet to look for affordable apartments in New York City. Every time she clicks on a link to a webpage,
    9·1 answer
  • A date consists of a month, day, and year. Consider the class Date of such dates. Suppose that Date represents the month, day, a
    14·1 answer
  • All file types have unique _____________________ that determine which program to use to open a particular file and to access its
    14·1 answer
  • Why RAM is necessary in a computer​
    9·1 answer
  • Which of the following would most likely be the target audience for a product
    7·2 answers
  • Complete the code to create a new file.
    6·1 answer
  • which of the following is a scenario in which an it support technician would most likely be required to implement the alternate
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!