___ | Algorithm | a. The rules that tell which statements (instructions) are legal, or accepted by the programming language, and which are not. |
___ | High-Level Language | b. Code written in machine language (0's and 1's). |
___ | Machine Code | c. The starting point of program execution, defined as main(). |
___ | Syntax | d. A clear and ordered set of steps that a computer can follow to solve a problem. |
___ | Program Entry Point | e. A programming language which abstracts away the intricate details of how the computer handles bits and machine code. |
___ | Output Stream | a. The operator used to insert data into an output stream. It places the provided data into cout for display on the terminal. |
___ | Stream Insertion Operator | b. A mechanism that allows data to be sent from a C++ program to an external destination, usually the terminal (console). |
___ | Assignment Statement | c. An operator used with cin to extract input from the input stream and store it in a variable. |
___ | Input Stream | d. A statement that assigns a value to a variable using the = operator |
___ | Stream Extraction Operator | e. A data flow mechanism that sends information from an external source (e.g., keyboard) into a program. |
___ | Integral Data | a. The process of reserving memory space for data or instructions during a program’s execution. |
___ | Floating-Point Data | b. The process of defining a variable by specifying its data type and identifier. |
___ | ASCII (American Standard Code for Information Interchange) | c. Any data type that stores decimal numbers. |
___ | Variable | d. A user-defined name assigned to a variable, function, or other entities in C++. |
___ | Memory Allocation | e. A character encoding standard where each character is mapped to a numerical value (0-255). |
___ | Identifier | f. Any data type that stores whole numbers (without decimals). |
___ | Variable Declaration | g. A name (identifier) given to an address (byte) or grouping of addresses in memory. When a variable is created, memory is allocated. |
___ | Integer Division | a. Division where both operands are integers, resulting in an integer with the decimal part discarded. |
___ | Floating-Point Division | b. An arithmetic expression that combines integer and floating-point values. |
___ | Mixed Expression | c. Forcibly converting a value from one data type to another through the use of a cast operator. |
___ | Implicit Typecast | d. Division where at least one operand is a floating-point value, resulting in a decimal value. |
___ | Explicit Typecast | e. The automatic conversion of one data type to another by the compiler, such as converting an integer to a floating-point value in a mixed expression. |
<cmath>
and <iomanip>
).___ | pow(x, y) | a. Square Root |
___ | sqrt(x) | b. How many floating-point digits to show |
___ | abs(x) | c. Absolute Value |
___ | floor(x) | d. Sets how many spaces the next piece of data to be output will take at minimum |
___ | ceil(x) | e. Exponent |
___ | setprecision(int) | f. Displays output floating-point numbers in fixed-point notation |
___ | fixed | g. Round Up |
___ | setw(int) | h. Sets the character to fill the blank spaces of `setw()` with |
___ | setfill(char) | i. Round Down |
___ | Relational Operator | a. An operator that combines or modifies boolean expressions. |
___ | Logical Operator | b. A control structure that allows a program to choose between more than 2 possible execution paths. |
___ | One-Way Selection | c. An operator that allows relational comparisons to be made in a program. |
___ | Two-Way Selection | d. A control structure that chooses one case from many possible cases based on the value of an integral expression. |
___ | N-Way (Multiple) Selection | e. A single block of code that executes only if a condition is true . |
___ | Switch Statement | f. A control structure that chooses between two possible paths of execution, depending on whether a condition is true or false . |
main.cpp
.main()
function?<iostream>
library?<cmath>
library?<iomanip>
library?Mario | valid/invalid | ______________ |
1uigi | valid/invalid | ______________ |
Pe@ch | valid/invalid | ______________ |
D4isy | valid/invalid | ______________ |
Mickey Mouse | valid/invalid | ______________ |
int a = 2, b = 5; double c = -5.5; cout << static_cast<int>(pow(b / a, a) + abs(c));
What will the following snippet output:
double a = 8.63216; int b = 18, c = 4; cout << static_cast<int>(a + static_cast<double>(b) / c)`;
double a = 10.0, b = 4.0; double c = a / b; cout << setprecision(2) << c << endl;
cout
statement be modified to make the setprecision()
output the value showing 2 decimal places in fixed-point notation?setw()
and how the left
and right
operators effect it.switch
statement expressions be?break
statement is left out of a case
in a switch
statement?int a = 20.0, b = 3.0; double c = 20.0, d = 3.0; a / b > 6 && c / d > 6
What prints if the user enters: (a) 11, (b) 23, and (c) 17?int a = 10, b = 5; cout << "Enter a value: "; cin >> a; if (a % b == 1) { cout << "If" << endl; } else if (a % b == 3) { cout << "Else if" << endl; } else { cout << "Else" << endl; }
In the following program fix all the errors (write the fixes directly on the code)
# include <iostream> using namespace std; int main() { int a = 5 b = a + 10; cout << b << " + 10 = " << b << endl; return 0; }
In the following program fix all the errors (write the fixes directly on the code)
# include <iostream> using namespace std; int main() { int bottles = 0; double ounces = 5.5; double total = bottles * ounces; cout >> "How many bottles do you have: "; cin cout >> bottles >> " bottles of " >> ounces >> "oz is " >> total >> "oz total\n"; return 0; }
In the following program fix all the errors (write the fixes directly on the code)
# include <iostream> using namespace std; int main() { double radius = 0.0; const double pi = 3.14159265359; cout << "Radius: "; cin >> radius; double area = pi * pow(radius, 2); cout << setprecision(2) << pi << " * " << radius << "^2 = " << area << endl; return 0; }
Write a program that reads an integer length in inches, converts the read in length from integer inches to floating-point feet, then from floating-point feet to floating-point yards. Then, output the calculated values using the following output manipulation:
x -> y
) should be left justified with a width of 20.Note: There are 12 inches in a foot, and 3 feet in a yard.
Note: No error checking needs to be done.
Example Program Interaction
Inches: 275 Inches -> Feet 22.917 Feet -> Yards 7.639
Write a program that reads an integer length in centimeters, converts the read in length from integer centimeters to floating-point meters, then from floating-point meters to floating-point kilometers. Then, output the calculated values using the following output manipulation:
x -> y
) should be left justified with a width of 25.-
.Note: There are 100 centimeters in a meter, and 1000 meters in a kilometer.
Note: No error checking needs to be done.
Example Program Interaction
Centimeters: 287541 Centimeter -> Meter--------------2875.41 Meter -> Kilometer------------------2.88
Write a program that reads a floating-point side length of a decagon, then error checks the value entered for input failure and that it is greater than 0. If input failure occurs or the input is less than 0, display an error and quit the program. If a valid value is read in the user should then select ’a’
or ’A’
to calculate the area or ’p’
or ’P’
to calculate the perimeter by the program reading in a character. A switch statement should then be used to calculate only the area or perimeter and output the respective result, or output an invalid selection message based on the character the user entered.
Formulas:
Example Program Interactions
Decagon Side Length: 6.8 (A/a)rea -or- (P/p)erimeter: a Area: 355.78
Decagon Side Length: 6.8 (A/a)rea -or- (P/p)erimeter: P Perimeter: 68.00
Decagon Side Length: 6.8 (A/a)rea -or- (P/p)erimeter: e Invalid selection
Write a program that reads a floating-point side length of a hexagon, then error checks the value entered for input failure and that it is greater than 0. If input failure occurs or the input is less than 0, display an error and quit the program. If a valid value is read in the user should then select ’a’
or ’A’
to calculate the area or ’p’
or ’P’
to calculate the perimeter by the program reading in a character. A switch statement should then be used to calculate only the area or perimeter and output the respective result, or output an invalid selection message based on the character the user entered.
Formulas:
Example Program Interaction
Decagon Side Length: 7.2 (A/a)rea -or- (P/p)erimeter: a Area: 134.68
Decagon Side Length: 6.8 (A/a)rea -or- (P/p)erimeter: P Perimeter: 43.20
Decagon Side Length: 6.8 (A/a)rea -or- (P/p)erimeter: e Invalid selection