Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

c++ test question. Question 22 Write a value returning function definition (both

ID: 3570729 • Letter: C

Question

c++ test question.

Question 22

Write a value returning function definition (both the heading and body) named sumplusten. Send the function three integers from main and return the sum of the three integer values plus 10.

Question 23

Write the prototype for the function sumplusten you wrote in the previous question.

Question 24

For the following question you will need to use an output operator ( << ). Be sure you enter a blank space AFTER this operator so I will be able to read and grade your answer.

Write a main program (no include statements) that calls the function sumplusten from the previous question. Be sure to include the following:

Explanation / Answer

For the prototypes, you may want to exlude the identifiers (parameter names); it's just a matter of style and works with them or without them. The code can also be found here: http://pastebin.com/p2uZsWT6.

/* SumPlusTen.cpp */
#include <iostream>

using namespace std;

//Question 23: sumplusten function prototype
int sumplusten(int num1, int num2, int num3);

//Question 24: main program demonstrating sumplusten
int main(void) {
    int n1, n2, n3;
    n1 = 5;
    n2 = 10;
    n3 = 3;

    int sump10;
    sump10 = sumplusten(n1, n2, n3);

    cout << "The sum of n1, n2, and n3 plus 10 is " << sump10 << " ";

    return 0;
}

//Question 22: sumplusten function definition
int sumplusten(int num1, int num2, int num3) {
    return num1 + num2 + num3 + 10;
}


/* SumProduct.cpp */

#include <iostream>

using namespace std;

//Question 26: sumproduct function prototype
void sumproduct(double num1, double num2, double num3, double &sum, double &product);

//Question 27: main program demonstrating sumproduct
int main(void) {
    double n1, n2, n3;
    n1 = 13.5;
    n2 = 2.11;
    n3 = 5.0;

    double nsum = 0, nprod = 0;
    sumproduct(n1, n2, n3, nsum, nprod);

    cout << "The sum of n1, n2, and n3 is " << nsum << " ";
    cout << "The product of n1, n2, and n3 is " << nprod << " ";

    return 0;
}

//Question 25: sumproduct function definition
void sumproduct(double num1, double num2, double num3, double &sum, double &product) {
    sum = num1 + num2 + num3;
    product = num1 * num2 * num3;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote