C++ Beginner Skill Assessment Practice Test

Last Updated :
Discuss
Comments

Question 1

What is the file extension for a C++ source file?

  • A

    .c

  • B

    .cpp

  • C

    .h

  • D

    .exe

Question 2

Which among the following symbol is used to comment a single line in C++?

  • A

    #

  • B

    /*

  • C

    //

  • D

    \\

Question 3

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

C++
#include <iostream>
using namespace std;

int main()
{
    cout << "Hello, World!" << endl;
    return 0;
}
  • A

    Hello, World

  • B

    Hello, World!

  • C

    Hello World!

  • D

    Hello World

Question 4

Which among the following data types is used to store a single character in C++?

  • A

    int

  • B

    char

  • C

    float

  • D

    double

Question 5

What is the size of an int data type in C++ (on most systems)?

  • A

    2 bytes

  • B

    1 byte

  • C

    8 bytes

  • D

    4 bytes

Question 6

Which of the following declares a single-precision floating-point variable in C++?

  • A

    int x = 3.14;

  • B

    float x = 3.14;

  • C

    char x = 3.14;

  • D

    double x = 3.14;

Question 7

What is the default value of a global variable in C++?

  • A

    0

  • B

    undefined

  • C

    garbage value

  • D

    null

Question 8

Which of the following is true about static variables?

  • A

    They are reinitialized every time the function is called.

  • B

    They retain their value between function calls.

  • C

    They can only be declared within a function.

  • D

    They cannot be initialized.

Question 9

Where can a local variable be accessed in C++?

  • A

    Only within the block it is declared

  • B

    Throughout the entire program

  • C

    Within the file it is declared

  • D

    Within the function it is declared

Question 10

How do you access a global variable named x when there is a local variable with the same name?

  • A

    global::x

  • B

    ::x

  • C

    x

  • D

    global_x

There are 50 questions to complete.

Take a part in the ongoing discussion