C++ Basics: Declaration, Data Types, I/O, and Math Functions

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/17

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 2:17 AM on 9/10/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

18 Terms

1
New cards

What is the difference between declaration and initialization in C++?

Declaration allocates memory space, while initialization assigns an initial value.

2
New cards

What does the C++ declaration 'int count;' do?

It declares a variable 'count' of type integer.

3
New cards

What is the purpose of the 'const' keyword in C++?

It marks a variable as a constant, meaning it cannot be modified after initialization.

4
New cards

What is the output operator in C++?

The output operator '<

5
New cards

How do you read user input in C++?

Using the extraction operator '>>' with 'cin'.

6
New cards

What is the issue with using 'cin' followed by 'getline()'?

The trailing newline left in the input buffer can cause 'getline()' to read an empty line.

7
New cards

How can you fix the newline buffer issue in C++?

Use 'cin.ignore()' to flush the newline buffer before calling 'getline()'.

8
New cards

What happens during integer division by zero in C++?

It causes a runtime crash (floating-point exception).

9
New cards

What is the result of floating-point division by zero in C++?

It returns special IEEE values like 'inf' (infinity) or 'nan' (not a number).

10
New cards

What does the increment operator '++' do?

It adds 1 to the variable.

11
New cards

What is the purpose of compound assignment operators in C++?

They perform an operation and reassign the result to the variable.

12
New cards

What is explicit type casting in C++?

It converts an expression to a specified type using 'static_cast(var)'.

13
New cards

What is the function of 'pow(x, y)' in ?

It raises x to the power of y (x^y) and returns a double.

14
New cards

What does 'sqrt(n)' return in ?

It returns the square root of n (√n).

15
New cards

What does 'fabs(n)' do?

It returns the absolute value of a floating-point number |n|.

16
New cards

What does the escape sequence '\n' do in C++?

It inserts a new line in a string literal.

17
New cards

How do you display a literal double quote in a string in C++?

Use the escape sequence '"'.

18
New cards

What does the escape sequence '\\' represent?

It displays a single backslash in a string.