C++ Beginner Skill Assessment Practice Test

Last Updated :
Discuss
Comments

Question 1

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

  • .c

  • .cpp

  • .h

  • .exe

Question 2

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

  • #

  • /*

  • //

  • \\

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;
}
  • Hello, World

  • Hello, World!

  • Hello World!

  • Hello World

Question 4

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

  • int

  • char

  • float

  • double

Question 5

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

  • 2 bytes

  • 1 byte

  • 8 bytes

  • 4 bytes

Question 6

How do you declare a floating-point variable in C++?

  • int x = 3.14;

  • float x = 3.14;

  • char x = 3.14;

  • double x = 3.14;

Question 7

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

  • 0

  • undefined

  • garbage value

  • null

Question 8

Which of the following is true about static variables?

  • They are reinitialized every time the function is called.

  • They retain their value between function calls.

  • They can only be declared within a function.

  • They cannot be initialized.

Question 9

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

  • Only within the block it is declared

  • Throughout the entire program

  • Within the file it is declared

  • 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?

  • global::x

  • ::x

  • x

  • global_x

There are 50 questions to complete.

Take a part in the ongoing discussion