204k views
2 votes
Which line in the following program contains the prototype for the showDub function?

1 #include
2 using namespace std;
3
4 void showDub(int);
5
6 int main()
7 {
8 int x = 2;
9
10 showDub(x);
11 cout << x << endl;
12 return 0;
13 }
14
15 void showDub(int num)
16 {
17 cout << (num * 2) << endl;
18 }

A) 4
B) 6
C) 10
D) 15

User Terson
by
7.3k points

1 Answer

4 votes

Final answer:

The prototype for the showDub function is found in line 4 of the program. It consists of the return type (void), the name of the function (showDub), and the parameter types (a single integer).

Step-by-step explanation:

The prototype for the showDub function is contained in line 4 of the program provided. A function prototype tells the compiler about a function's name, return type, and parameters before its actual definition is encountered in the code. The prototype does not contain the function body but does include the following:

  • The return type of the function (void in this case, meaning the function does not return a value).
  • The name of the function (showDub).
  • The types of the parameters the function takes (a single int parameter).

So, the correct answer is A) 4.