Which line in the following program contains the prototype showDub function? 1 #include 2 using namespace std; 3 void showDub(int); 4 int main() 5 { 6 int x = 2; 7 showDub(x); 8 cout << x << endl; 9 return 0; 10 } 11 void showDub(int num) 12 { 13 cout << (num * 2) << endl; 14 }

Respuesta :

Answer:

Option 3 is the correct answer for the above question.

Explanation:

If any function is defined after the main function or any other function which is used to call that function then there needs a prototype defined before the calling function definition to tell the compiler that what type of that function is. for example, if a fun function is called by the main function and its definition is after the main function, then there needs to declare a function prototype before the main function definition.

The prototype syntax is "return_type function_name (argumen_type1, argument_type2)". This syntax is matched from option 3. Hence 3 is the correct answer for the above question while the other is not because:-

  • Option 1 states about the header file.
  • Option 2 states about the namespace name.
  • Option 4 states the main function.
  • Option 5 states about the curly braces.
  • Option 6, 7 and 8 states about the main function statement.
  • Option 9 states the return statement.
  • Option 10 states about the curly braces.
  • Option 11, 12, 13 and 14 states about the definition of showdub function.

ACCESS MORE
ACCESS MORE
ACCESS MORE
ACCESS MORE