Arithmetic Operators Flashcards

To understand Arithmetic Operators in C++

1
Q

What symbol is used for the addition operator?

A

The + sign (the plus sign)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why would we use the addition operator?

A

We use the addition operator to add two variables together or to figure out large addition problems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What happens if you add an integer of to a double?

A

You would result in a double answer, however if the addition ends up with a .0 at the end. It wouldn’t show and it would result in an int answer.
For example,
cout &laquo_space;7 + 3.14; prints 10.14
however
cout &laquo_space;7.0 + 3; prints 10
also it would remove irrelevant/additional 0s if available
cout &laquo_space;7.0 + 3.00140000; prints 10.0014

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the cout command considered to be?

A

It is considered to be non-specific because you can use the same syntax for all of your printing needs (e.g. cout &laquo_space;1; cout &laquo_space;“Hello”;, and cout &laquo_space;true;). However, for printing certain numbers, it is not always clear if what’s printed is an int or a double.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is printf()? What is different between it and cout?

A

printf() originates from the C language and, unlike the cout command, it is considered to be specific. This means that you must specify what type of data you want to print before you can use the command successfully.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When using the printf() command. What does \n do?

A

The \n in the printf() command creates a newline character and it causes the variables to be printed one below the other.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When using the printf() command. What is the %d for?

A

The %d tells the system to print an integer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When using the printf() command. What is the %f for?

A

The %f tells the system to print a floating point number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the difference between the %d and %f?

A

The %d orders the system to print an integer while %f orders to print a floating point number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What happens if you use an incorrect specifier?

A

If an incorrect specifier is used, you will recieve an error message.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How many zeros (after the decimal point) does the floating point number contains?

A

Floating point numbers contain six zeros after the decimal point if they are printed using printf().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What’s the difference between cout and printf()?

A

Unless you want to be specific with how your data is printed, you should always default to using cout. Only use printf() when formatting is important.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does it mean to increment a variable?

A

Incrementing a variable means to increase the value of a variable by a set amount. The most common incrementation is when a variable increments itself by the value of 1.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the incrementating equation?

A

The incrementating equation is a = a +1;
The new value of a is assigned the old value of a plus 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is string concatenation?

A

String concatenation is the act of combining two strings together. This is done with the + operator.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly