C++ Basics
Variables and Arrays
Looping Statement
Operators & Files
Functions
100

What is a correct syntax to output "Hello World" in C++?

cout<<"Hello World";

100

When would you use global variables

Never in this class. Global is for set items that will be repeatedly used throughout the program, like the constant pi if the math library did not exist

100

How do you start writing an if statement in C++?

if(x<y){  }

100

 C++ code line ends with ___

semicolon(;)

100

Every variable should be separated by .......... separator?

comma(,)

200

Type of language C++ is

Compiled (translates then runs) and Explicitly typecast (data type is predeclared and cannot be changed

200

Which header file lets us work with input and output objects?

#include<iostream.h>

200

Which statement is used to stop a loop?

break

200

This is needed at the end of the file you are trying to open because C++ does not assume the file type.

file extension (.txt, .csv)

200

To make large programs more manageable programmers modularize them into groups of code that can be called repeatedly that are called_______

Functions

300

Built in data types

char, int, double, Boolean, float

300

To declare an array in C++, define the variable type with:

[]

300

What is the index number of the last element of an array with 9 elements?

8

300

Library needed to work with external files

fstream

300

Three main parts of a function:

Return/ data type

Parameters

Body of code

400

Which data type is used to create a variable that should store text?

string

400

T or F: Length must be predetermined for vectors.

False

400

How many times will this nested loop execute?

for(int i=0; i<4; i++)

{ cout<<"Strike: ";

      for(int j=0; i<3; i++)

{//body}

}

12

400

Opening a file that exists in writing mode does?

Wipes all content that exists in the file.

400

A function that need no return value is called

void function

500

How do you create a variable with the number 2.8?  

float x=2.8;

OR

double x=2.8;

500

Vector functions needed to insert a data item to a certain position

vector.insert.( vector.begin() + index position, item)

500

What is the expected output of the following loop:

for(int i=0; i<=5; i--)

{

    cout<< i << " ";

}

0, -1, -2, -3. . . 

The loop is infinite

500

Reading method that loops until end of file (include lines of code)

while(!infile.eof())

{   infile>> var;

   if(!infile.fail())

{cout<< var;}

}

500

Allows a function to modify a variable without creating a copy

Pass by reference

M
e
n
u