Section A: Theory
1.1 What is the purpose of a return type in a function declaration?
1.2 What is the difference between a function declaration and a function definition?
1.3 Explain the concept of function overloading with an example.
1.4 Why should functions use parameters instead of relying only on global variables?
Section B: Code Output
For each of the following C++ code snippets, write the output as it will appear on the screen.
2.1 2.2
#include <iostream> #include <iostream>
using namespace std; using namespace std;
int main() { int main() {
for(int i = 1; i <= 3; for(int i = 3; i >= 1; i--)
i++) { {
for(int j = 1; j <= i; for(int j = 1; j <= i;
j++) { j++) {
cout << "*"; cout << j;
} }
cout << endl; cout << endl;
} }
return 0; return 0;
Section C: Programming Questions
3.1 Write a program that does the following:
Declares an array of 5 integers
Allows the user to input values into the array
Prints the array in reverse order
3.2 Write a program that:
Prompts the user to enter a floating point number
Displays the square root and the power of that number raised to 3
3.3 Write a function called isEven that takes an integer parameter and returns true if it is even,
otherwise false. In main(), read an integer from the user and use the function to
determine if it is even or not.