EmSAT Computer Science C++ Mock Test 2024 Questions Answers:

EmSAT Computer Science C++ Mock Test 2024 Questions Answers: Our free EmSAT Programming and Problem-Solving (C++) mock test is a practice test designed for students who are preparing to take the official EmSAT exam in the UAE. This mock test is specifically focused on testing the student’s knowledge and skills in programming and problem-solving using C++ language.

The EmSAT Computer Science C++ Mock Test is typically structured in a similar way to the official EmSAT exam, and consists of a set of multiple-choice questions that cover various topics such as variables, control structures, data structures, functions, debugging, and problem-solving. Additionally, check EmSAT Computer Science Achieve Mock Tests.

The purpose of this mock test is to help students identify their strengths and weaknesses in the subject matter and to provide them with an opportunity to practice their test-taking skills. It also helps students to become familiar with the format and structure of the official EmSAT Computer Science exam.

EmSAT Computer Science C++ Mock Test

Mock Tests
/56

EmSAT Computer Science Mock Test
Section 4: Programming and Problem Solving (C++)
Total Questions: 56
Time Limit: 60 Minutes

1 / 56

1)
What is the output of the following code?

#include 
using namespace std;

void myFunction(int x) {
for (int i = 1; i <= x; i++) {
cout << i << " ";
}
}

int main() {
myFunction(5);
return 0;
}

2 / 56

2) What is the output of the following code?

#include 
using namespace std;

int myFunction(int x) {
return x * 2;
}

int main() {
int y = myFunction(3);
cout << y;
return 0;
}

3 / 56

3)
What is the output of the following user-defined function in C++?

void printMsg(string msg) {
cout << "The message is: " << msg << endl;
}

int main() {
string message = "Hello, world!";
printMsg(message);
return 0;
}

4 / 56

4) What is the output of the following user-defined function in C++?

int add(int x, int y) {
return x + y;
}

int main() {
int a = 5, b = 3;
int sum = add(a, b);
cout << sum;
return 0;
}

5 / 56

5) Which built-in function can be used to generate a random number in a specific range?

6 / 56

6) Which built-in function can be used to convert a string to an integer?

7 / 56

7) Which of the following is an example of a two-dimensional array in C++?

8 / 56

8) How do you initialize all elements of an array to the same value in C++?

9 / 56

9) Which of the following is the correct way to declare an array of strings in C++?

10 / 56

10) Which of the following correctly declares an array of integers in C++?

11 / 56

11) Which of the following is the correct syntax for declaring a variable in C++?

12 / 56

12) What is the difference between declaring a variable and initializing a variable in C++?

13 / 56

13) Which of the following data structures allows you to store multiple values of the same data type in a single variable?

14 / 56

14) Which keyword is used to declare a variable in C++?

15 / 56

15) Which of the following is not a built-in data type in C++?

16 / 56

16) When should you use a user-defined function in C++ instead of a built-in function?

17 / 56

17) Which of the following is an example of a built-in function in C++?

18 / 56

18) How do functions interact with each other in a program?

19 / 56

19) Which of the following is an example of a well-defined task that could be turned into a function?

20 / 56

20) What is a function in programming?

21 / 56

21) What is the purpose of decomposing a complex program into functions?

22 / 56

22) How are problem-solving skills used in programming?

23 / 56

23) What is the purpose of testing and debugging in C++ programming?

24 / 56

24) When selecting data structures in C++ programming, what is the primary consideration?

25 / 56

25) What is the purpose of a module in C++ programming?

26 / 56

26) Which of the following is an example of a built-in function in C++ programming?

27 / 56

27) Which of the following is not a type of control structure statement in C++ programming?

28 / 56

28) What is the output of the following C++ code?

#include 
using namespace std;
void recursive(int n)
{
if(n>0)
{
cout << n << " ";
recursive(n-2);
recursive(n-1);
}
}
int main()
{
recursive(5);
return 0;
}

29 / 56

29) What is the output of the following C++ code?

#include 
using namespace std;
void recursive(int n)
{
if(n>0)
{
recursive(n-1);
cout << n << " ";
recursive(n-2);
}
}
int main()
{
recursive(4);
return 0;
}

30 / 56

30) What is the output of the following C++ code?

#include 
using namespace std;
int recursive(int n)
{
if(n==0)
return 0;
else
return (n + recursive(n-1));
}
int main()
{
cout << recursive(5);
return 0;
}

31 / 56

31) What will be the output of the following C++ code?

for(int i=0; i<3; i++) {
for(int j=0; j<3; j++) {
if(i == j) {
continue;
}
cout << i * j << " ";
}
}

32 / 56

32) What will be the output of the following C++ code?

for(int i=1, j=5; i<=5; i++, j--) {
cout << i * j << " ";
}

33 / 56

33) What will be the output of the following C++ code?

int sum = 0;
for(int i=1; i<=10; i++) {
if(i%2 == 0) {
continue;
}
sum += i;
}
cout << sum;

34 / 56

34) What will be the output of the following C++ code snippet?

int num = 8;
switch(num%3) {
case 0:
cout << "Zero ";
case 1:
cout << "One ";
default:
cout << "Default ";
}

 

35 / 56

35) What is the output of the following code?

int x = 10, y = 5;
if(x > y)
if(y > 2)
cout << "x is greater than y and y is greater than 2";
else
cout << "x is greater than y and y is less than or equal to 2";
else
cout << "x is less than or equal to y";

36 / 56

36) What is the output of the following code?

int x = 5;
if(x > 10)
{
cout << "x is greater than 10";
}
else if(x > 5)
{
cout << "x is greater than 5";
}
else
{
cout << "x is less than or equal to 5";
}

37 / 56

37) What will be the output of the following code?

 

int x = 10;
if(x > 5)
{
cout << "x is greater than 5";
}
else
{
cout << "x is less than or equal to 5";
}

38 / 56

38) What is the output of the following code?

int i = 1;
while (i <= 10) {
if (i % 2 == 0) {
cout << i << endl;
}
i++;
}

39 / 56

39) Which of the following is not a control structure in C++?

40 / 56

40) When is it appropriate to use external data structures in C++?

41 / 56

41) Which of the following functions is used to write data to a file in C++?

42 / 56

42) Which function is used to read data from a file in C++?

43 / 56

43) What is the purpose of the fstream class in C++?

44 / 56

44) Which of the following is not a valid mode for opening a file in C++?

45 / 56

int num = 100;
while (num > 0) {
if (num % 7 == 0 && num % 3 == 0) {
cout << num << " is divisible by both 7 and 3." << endl;
}
num--;
}

45) How many times will the "if" statement in the above code be executed?

46 / 56

int num = 100;
while (num > 0) {
if (num % 7 == 0 && num % 3 == 0) {
cout << num << " is divisible by both 7 and 3." << endl;
}
num--;
}

46) What is the purpose of the if statement in the above code?

47 / 56

int num = 100;
while (num > 0) {
if (num % 7 == 0 && num % 3 == 0) {
cout << num << " is divisible by both 7 and 3." << endl;
}
num--;
}

47) What is the initial value of the variable num in the above code?

48 / 56

48) Which of the following data structures is designed to store elements in a specific order, and allows fast access to elements at the front and back of the structure?

49 / 56

49) Which of the following is a built-in C++ function that can be used to sort elements in an array or vector?

50 / 56

50) Which of the following statements is true about the use of data structures in programming?

51 / 56

51) What is the output of the following code snippet?


int i = 0;
while (i < 10) {
if (i % 2 == 0) {
i++;
continue;
}
cout << i << " ";
i++;
}

52 / 56

52) What is the output of the following code?

#include 
using namespace std;

int main() {
int num = 10;

if (num % 2 == 0) {
cout << "Num is even" << endl;
} else {
cout << "Num is odd" << endl;
}

return 0;
}

53 / 56

53) What will be the output of the following code?

int i = 10, j = 1;
do {
cout << i * j << " ";
j++;
} while (j <= 10);

 

54 / 56

54) What is the value of "x" after executing the following code?

double x = pow(2, 3) * sqrt(25) - ceil(4.6);

55 / 56

55) Which type of error occurs during program execution and can cause the program to crash or terminate unexpectedly?

56 / 56

56) Which type of error is caused by incorrect syntax in the code?

Your score is

0%