Programming and Print Statements
Variables and Error Messages
Mathematical Operations and Comments
Pointers and Memory
Strings
100

What is Programming?

Programming is giving the computer commands to do a specific task

100

What are the three types of error messages?

Syntax error

Logic error

Run-time error

100

What are comments? What are they used for?

Comments are a sentence of English that the compiler ignores


They are used to make it easier for other programmers to understand what the program is doing

100

What is a pointer?

A pointer is a type of variable that stores a memory address to data.

100

What is a string?

A string is just plain text

200

What is a Programming Language? Give 3 examples of a Programming Language.

Just like how there are many different ways you can give instructions or commands, there are many different programming languages that you can use to give commands to the computer

Examples: Java, Python, C++, Ruby, HTML, CSS, JavaScript, etc.

200

How to create a variable?

  1. Write down the type of variable you want to create

  2. Write down the name you want to give to your variable

  3. Write the equal sign (=) next to the variable name

  4. Write what you want your variable to be equal to and a semicolon after it

200

What are two ways you can write a comment? How do you write a comment in both ways?

There are one line comments and two line or more comments

To write a one line comment, you put “//” at the beginning of the comment

To write a two line or more comment, you put a “*/” at the beginning of the comment and a “/*” at the end of the comment

200

How to make a new pointer?

Same way as making a variable, but an asterix before the name

200
How to make a string?

Same in java, but string instead of String at the beginning

300

Which programming language are we using in this class and why?

We will be using C++ in this class because…

  • One of the world's most popular programming languages

  • Closely related to C and Java

300

What are variables? What are the types of variables you learned? What does each type of variable store?

Variables are objects that store information and you can change the stored information of any variable.

Types of Variables: int, double, boolean, String, char

Int: stores numbers without decimals

Double: stores numbers with and without decimals

boolean: stores either true or false

char: stores either single digit numbers or a single letter


300

What can you use the addition operation for?

You can use it to add two variable, two numbers, or two strings

300

Difference between pointers and variables

Variables hold data directly, while pointers hold memory addresses of data

300
Difference between Strings and Char arrays?
No essential difference, but operations are done manually in char arrays
400

What are print statements? What types of print statements did you learn? How do you write both types of print statements?

Print Statements allow you to print words or sentences on the screen

There are print statements with a newline and without a newline

Print statement with a newline: cout << endl;

Print statement without a newline: cout << ;

400

When do you receive each type of error message?

Syntax Errors

Syntax errors are errors in which you type something in your code that the compiler does not understand. 


Logic Errors

Logic Errors are errors where your code can run successfully, but the output of your code isn’t what you want it to output.


Run-Time Errors

Run-Time errors are errors that show up when your code is ran. These errors show in the console in red, and include a line number where the error occurred.

400

What is Modulus? What is its symbol? How does it work?

Modulus is a mathematical operation that it divides the 2 numbers and gives the remainder of it.

To find the modulus of 2 numbers, you would use the “%” sign. 


400

What is memory?

Memory is the piece of hardware on your computer that stores all variables used by programs running on the computer.

400

Difference between Strings and char pointers?

Again no essential difference, but char pointer requires two steps to create

500

What will the code output?

cout << "Hello!" << endl;

cout << "Good ";

cout << "Morning!" << endl;

Output:

Hello!

Good Morning!

500

What are the variable naming rules?

  • All variable names must begin with a letter, an underscore (_), or a dollar sign ($).  

  • After the first letter, variable names may also contain letters and the digits 0 to 9.  No spaces or special characters are allowed.

  • The name can be of any length

  • Remember that variable names are case-sensitive

  • You cannot use a C++ keyword (reserved word) for a variable name

500

How do you change the integer division to regular division?

To change the integer division to regular division, you can add a decimal point and a zero to either the the numerator or the denominator

Example:

int amountOfJuice = 80;

amountOfJuice = 80.0/60;

500

Relation between memory and an array?

Memory is technically a very long array of zeros and ones that the computer uses to store data.

500

How to make char pointer?

char *<variable name> = new char[<length of string + 1>];

strcpy(<variable name>, <string you want to store>);

M
e
n
u