Input / output
Vocabulary
Datatypes
If/else/switch
General Questions
100

How would we output something to the user and get input from the user.  

cout << "outputs to user";

cin >> inputUserData;

100

A programmable machine designed to follow instructions is?

Computer 

100

How many bytes are in a char


char x = 'A';

1 Byte

100

will this if statement execute?    Given: x =2;

if(x==2){

cout << "hello";

}

yes it will output hello. 

  if(Expression is true){

        statement;  

100

What is the pre processor directive of a program?

#include <iostream>


Remember #includes dont have ;

200

What is the keyword to format the width of a cout statement. 

cout << setw();

setw() lets us set the width of output

200

This retrieves and decodes program instructions, its part of the CPU 

Control Unit

200

What's the ASCII value of A

-keep in mind uppercase A and lowercase a have different ASCII values

65

200

Will this run?

int x =3;

if(x= 4){

cout << "Hello";

}

Yes it will output hello.
So question is why?
Because in the if() we let x new value be 4
instead of asking if x == 4. 

200

What's the difference between Procedural programming and OOP (object-oriented-programming)

Procedural programming focuses on the process and functions to process data. 

OOP focuses on objects working together to manipulate data. 

300

Using the #include <iomanip> header file, how can we set the decimal places to 4 of a variable?

Assume double x = 3.333365; 

cout << fixed << showpoint << setprecision(4);

300

its a hardware on CPU optimized for high speed calculations and true/false logic

Arithmetic and Logic unit

300

How can I cast only one type of datatype if i wish to do so. 

Ex: lets say i have int x =5; and double y = 5.5;

I want x+y to be casted as an int 

static_cast<int>

so when u do x+y it'll be 10.

300

Whats the output?

int x = 10;

if(x == 1){

cout <<"A" << endl;

}

else if(x == 9){

cout << "B" << endl;

}

else{

cout << "C" << endl;

}

The correct answer is C

300

The keyword sizeof()  does what?

Also how many bytes of data are in a int?

sizeof() checks the byte of a variable

int has 4 bytes. 

400

What are the three outputs of the following. 

int x = 0;

while(x < 3){

cout << ++x;

}


Solution :

1

2

3

400

This is volatile(Temporary) and is erased when the computer is not on. 

Main Memory (RAM)

400

Type Coercion Promotion is when you...

You convert to a higher datatype. 

Example: 

cout << 50.5 + 50;

This outputs 100.50 since double is greater than int.

400

Is this code okay?     Given x = 1;

switch(x){

case 1: cout << "hello" << endl;

case 5: cout << "answer was 5" ;

}

Yes, there is something wrong. 

since we did not put a break statement the program keeps on going. 

400

What does PEMDAS stand for? 

How does the computer execute code (which direction)? 

Parenthesis, Exponents, Multiplication, Division, Addition, Subtraction.

From Left to Right

----------->


500

What are the two ways we can go to the next line in our console output. 

cout << endl;

OR

cout << "\n";

500

What is a Literal? 

its a value written into the program. Like the name suggests a literal does not have a variable.

Example: 

cout << 12;                  both 12 and "hi" are literals

cout << "hi" 

500

This datatype is used as a flag it can represent 1 or 0. 

Bool 


Declare: bool x = true  for 1; false for 0

500

What numbers are allowed 

if( x > 0 && x <101){

      if(x != 55){   cout << "Hello" ;}

}

numbers from 1 to 100 can be executed with the loop
However u cannot have 55

500
What's the output for the following?


cout << 12/3*10  << endl; 

cout << 10*3/12;

40 

2.5

M
e
n
u