Intro to C++
SOC
Variables
Control Statements
Mekus Mekus
100

Who developed C language?

Bjarne Stroustrup

100

Determines how we organize the elements in our code to make it legible to the computer. If there’s a syntax error, the computer might not be able to read it.

Syntax

100

A container (storage area) to hold data.

Variable/Variables

100

Is used in a programming language to control the flow of the program.

Control Statement

100

What is the main difference between C and C++?

The main difference between C and C++ is that C++ support classes and objects

200

How many times C++ programming language was updated?

4

200

Give one example of what programming syntax can determine.

  • whether we use lower-case or upper-case characters
  • how we notate code comments
  • how we use whitespace
  • how we indicate the relationships between statements (individual commands issued to the computer)
200

Stores floating point numbers, with decimals.

Double

200

What is the syntax for switch case statement?

switch(expression)

{

case value1:

//code should be executed;

break;

case value2:

//code should be executed;

break;

Default:

//Code to execute if not all cases matched

break;

}

200

Are also a form of interaction between the computer and the user.

Output

300

Which programming language that has the OOP features of C++?

Simula67

300

The compiler considers these as non-executable statements.

Comment

300

Stores single characters, such as 'a' or 'B'.

char

300

What is the syntax for if statement?

if(condition)

{

//code should be executed;

}

300

Are text notes added to the program to provide explanatory information about the source code.

Comments

400

As C++ is close to ____ and ____, it makes it easy for programmers to switch to C++ or vice versa.

C# and Java

400

A mixture of natural language and high-level programming language.

Pseudocode

400

All C++ variables must be identified with unique names. These unique names are called ____ .

Identifiers

400

What is the syntax for for loop control statement?

for(initialization; condition; incr/decr){

//code should be executed;

}

400

Give at least one rule for naming a variable.

  • A variable name can only have alphabets, numbers, and the underscore _.
  • A variable name cannot begin with a number.
  • It is a preferred practice to begin variable names with a lowercase character. For example, the name is preferable to Name.
  • A variable name cannot be a keyword. For example, int is a keyword that is used to denote integers.
  • Names cannot contain whitespaces or special characters like !, #, %, etc.
  • A variable name can start with an underscore. However, it's not considered a good practice.
500

Enumerate the four primary features of OOP that supports C++.

Encapsulation, Polymorphism, Abstraction, and Inheritance

500

Is used by the programmer to make others understand his/her intent. It contains the summary of the code.

Code description

500

This will declare the variable as "constant", which means unchangeable and read-only.

const

500

What is the syntax for nested for loop?

for (initialization; condition; increment) {

for (initialization; condition; increment) {

// set of statements for inner loop

}

//set of statement for outer loop

}

500

Write the source code of the display output.

1-1

1-2

1-3

2-1

2-2

2-3

3-1

3-2

3-3

#include <iostream>

using namespace std;


int main(){

for (int x = 1; x <= 3; x++){

for(int y = 1; y <=3; y++)

{

cout << x << "-" << y "\n";

}

}

}