What is a correct syntax to output "Hello World" in C++?
cout<<"Hello World";
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
How do you start writing an if statement in C++?
if(x<y){ }
C++ code line ends with ___
semicolon(;)
Every variable should be separated by .......... separator?
comma(,)
Type of language C++ is
Compiled (translates then runs) and Explicitly typecast (data type is predeclared and cannot be changed
Which header file lets us work with input and output objects?
#include<iostream.h>
Which statement is used to stop a loop?
break
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)
To make large programs more manageable programmers modularize them into groups of code that can be called repeatedly that are called_______
Functions
Built in data types
char, int, double, Boolean, float
To declare an array in C++, define the variable type with:
[]
What is the index number of the last element of an array with 9 elements?
8
Library needed to work with external files
fstream
Three main parts of a function:
Parameters
Body of code
Which data type is used to create a variable that should store text?
string
T or F: Length must be predetermined for vectors.
False
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
Opening a file that exists in writing mode does?
Wipes all content that exists in the file.
A function that need no return value is called
void function
How do you create a variable with the number 2.8?
float x=2.8;
OR
double x=2.8;
Vector functions needed to insert a data item to a certain position
vector.insert.( vector.begin() + index position, item)
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
Reading method that loops until end of file (include lines of code)
while(!infile.eof())
{ infile>> var;
if(!infile.fail())
{cout<< var;}
}
Allows a function to modify a variable without creating a copy
Pass by reference