GD
SYNTAX
VARIABLES
DATA TYPES
OPERATORS
INPUT
CHALLENGES

Test Your Knowledge

Variables

You Scored % - /
1. What is the difference between a variable's name and its identifier?
2. What is the scope of a local variable?
3. What is the value of the variable x after the following code is executed?
int x = 5;
x = x + 2;
4. What is the correct way to initialize a C++ variable?
5. Create a variable named myNum and assign the value 50 to it.
= ;
6. Display the sum of 5 + 10, using two variables: x and y.
= ;
int y = 10;
cout << x + y;
7. Create a variable called z, assign x + y to it, and display the result.
int x = 5;
int y = 10;
= x + y;
cout << ;
8. Fill in the missing parts to create three variables of the same type, using a comma-separated list:
x = 5 y = 6 z = 50;
cout << x + y + z;
  • main.cpp
 

Download Result

Close File

Your changes will be lost. Are you sure you want to Close the file ?

Save

Do you want to save the file ?

About

Online C++ IDE is a web-based tool powered by ACE code editor. This tool can be used to learn, build, run, test your python script. You can open the script from your local and continue to build using this IDE. Code and output can be downloaded to local.

Keyboard Shortcuts

  • Run Code - F8
  • Save Code - F10
  • Open Editor Command Palette - F1

Report a bug

If you encounter a bug or have questions or suggestions for improvements, please report it via feedback.

Data policy

No data is saved in the server. The code is sent to the server for execution and will be cleared after completion. Shared Code will be saved in the server till the selected expiry period.