Question: Write C++ programs using a single main function. Hint: for each problem write a test function for it then call these test functions in the


Write C++ programs using a single main function. Hint: for each problem write a test function for it then call these test functions in the main function.
Section 2.3 12. Write a C++ function: int rectArea (int len, int wid) that returns the area of a rectangle with length len and width wid. Test it inside the main program that inputs the length and width of a rectangle and outputs its area. Output the value in the main program, not in the function. 13. Write a C++ function void rect (int& ar, int& per, int len, int wid) that computes the area ar and perimeter per of a rectangle with length len and width wid. Test it inside the main program that inputs the length and width of a rectangle and outputs its area and perimeter. Output the value in the main program, not in the procedure. Section 2.4 14. Write a C++ recursive function int fib(int n) that returns the value of the nth Fibonacci number. Do not use a loop. Test it in the main program, not in the function. The Fibonacci sequence is 0 1 1 2 3 5 8 13 21... Each Fibonacci nu ber the sum of the preceding Fibonacci nur //Lab1.cpp // add statement to include iostream // add statement to use namespace std // declare all functions except main function here int rectArea (int len, int wid); void testExercise12(); void rect (int & ar, int& per, int len, int wid); void testExercise13(); Int main() { cout
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
