Jared Sherrick
Quiz by , created more than 1 year ago

A quiz for FEH students over C/C++ material.

38
1
0
Jared Sherrick
Created by Jared Sherrick almost 8 years ago
Close

FEH C/C++ Quiz

Question 1 of 18

1

Fill the blank space to complete the text.

In C/C++, using the printf command to display something to the command terminal is the same as using the fprintf command except the fprintf command has as the first argument.

Explanation

Question 2 of 18

1

Which line of code below will generate a segmentation fault error when it compiles?

Select one of the following:

  • scanf("format", &var1, &var2);

  • scanf("format", &var1, &var2)

  • scanf("format", var1, var2);

  • scanf("format", var1, var2)

Explanation

Question 3 of 18

1

When reading a string with scanf, an & is required.

Select one of the following:

  • True
  • False

Explanation

Question 4 of 18

1

In the following code, which line(s) contains an error?

1 int main()
2 {
3 FILE fptr1;
4 int memes;
5 fptr = fopen("Exan.txt","r");
6 if (*fptr1 != NULL)
7 {
8 printf("File opened successfully!\n\n");
9 }
10 fscanf (fptr1, "%d", memes);

Select one of the following:

  • 3, 6, 10

  • 3, 10

  • 3, 6, 8

  • 8, 10

Explanation

Question 5 of 18

1

The following loop will stop executing when the end of file condition is detected (assume inptr has been declared as a file pointer already):
while (!feof(inptr))

Select one of the following:

  • True
  • False

Explanation

Question 6 of 18

5

--- This is the AND operator in C/C++
--- This is the OR operator in C/C++
--- This is the NOT operator in C/C++
--- This is the Assignment operator in C/C++
--- This is the Equality operator in C/C++

Drag and drop to complete the text.

    ==
    =
    !
    ||
    &&

Explanation

Question 7 of 18

1

Fill the blank space to complete the text.

When writing input and output in C++, it is necessary to write std:: before every cin and cout, unless you write .

Explanation

Question 8 of 18

1

Fill the blank space to complete the text.

When writing in C++, it is necessary to use this symbol on occasion "::". Its name is the operator.

Explanation

Question 9 of 18

1

<< ---
>> ---

Drag and drop to complete the text.

    Insertion Operator
    Extraction Operator
    Double Arrow Operator

Explanation

Question 10 of 18

1

Fill the blank space to complete the text.

Please enter the C++ command to open a file named Santa.txt. Note: assume a file pointer named fin has already been created.

Explanation

Question 11 of 18

1

A function prototype needs a semicolon to terminate it.

Select one of the following:

  • True
  • False

Explanation

Question 12 of 18

1

In the multidimensional array declared as in Christmas[3][4]; , The [3] refers to the number of columns, while the [4] refers to the number of rows.

Select one of the following:

  • True
  • False

Explanation

Question 13 of 18

1

Fill the blank spaces to complete the text.

Pointer math:
Assume pointer elf has an address of 2000 points to a value of 10. Solve the following questions using C math and pointer math.
elf + 4 = ;
pow(*elf, 2) = ;

Explanation

Question 14 of 18

1

A struct must be terminated with a semicolon before the int main().

Select one of the following:

  • True
  • False

Explanation

Question 15 of 18

1

All members of a struct are private.

Select one of the following:

  • True
  • False

Explanation

Question 16 of 18

1

A constructor function has a return type.

Select one of the following:

  • True
  • False

Explanation

Question 17 of 18

1

The dot (.) operator is used in classes to access class member data and functions.

Select one of the following:

  • True
  • False

Explanation

Question 18 of 18

1

Assume Claus is a pointer variable of the type of a struct that has already been declared. Assume Presents is a variable within the aforementioned struct that has a value of 20. When the code below executes, the line "Presents for all good boys and girls" will be printed to the screen.

if (Claus.Presents == 20) {
cout << "Presents for all good boys and girls\n";
}
else {
cout << "Naughty kids get coal!\n";
}

Select one of the following:

  • True
  • False

Explanation