Syntax in C++ MCQs Exercise II

Ques 1 Syntax


Which of the following is used to end the current line statement in C++?

A :
B ;
C }
D )

Ques 2 Syntax


What is the correct syntax for a C++ function that takes two integer parameters and returns an integer?

A int function(int a, int b): return int;
B return int function(int a, int b);
C int function(int a, int b) { return a + b; }
D int function(int a, int b) => return a + b;

Ques 3 Syntax


What is the correct way to write a C++ if statement that prints "Hello" if the variable "x" is greater than 10?

A if x > 10 { cout << "Hello"; }
B if (x > 10) { cout << "Hello"; }
C if x > 10 then cout << "Hello";
D if x > 10 print "Hello";