Expanded_CPP_Flashcards_Test1_Review.pdf
Document Details
Uploaded by DevoutDysprosium
Texas State University
Tags
Full Transcript
C++ Programming Flashcards - Expanded Test 1 Review Flashcard Set 1: Introduction to Programming & Hardware Components Q: What are the main hardware components of a computer? A: CPU (Processor), RAM (Main Memory), Secondary Storage (Disk, SSD), Input and Output Devices. Q: What is t...
C++ Programming Flashcards - Expanded Test 1 Review Flashcard Set 1: Introduction to Programming & Hardware Components Q: What are the main hardware components of a computer? A: CPU (Processor), RAM (Main Memory), Secondary Storage (Disk, SSD), Input and Output Devices. Q: What is the function of RAM (Main Memory)? A: It stores data temporarily for quick access by the CPU. Q: What is secondary storage, and how does it differ from RAM? A: Secondary storage (e.g., disk, SSD) stores data permanently, while RAM stores data temporarily. Q: Define an algorithm. A: A step-by-step procedure for solving a problem or performing a task. Flashcard Set 2: C++ Basics and Constants Q: What are constants in C++ and how are they declared? A: Constants are variables whose value cannot be changed after being set. They are declared using the 'const' keyword, e.g., const int MAX = 100. Q: What are the main C++ data types used for variables? A: int, double, char, string. Q: How do you write a constant variable in C++? A: Use the 'const' keyword, e.g., const int MAX = 100. Flashcard Set 3: Expressions and Data Types Q: What does the expression 'y = 3 + 2 * x' evaluate to if 'x = 5'? A: 13, because multiplication has higher precedence than addition. Q: How does C++ handle type conversions in expressions involving different data types? A: C++ automatically promotes smaller types to larger types (e.g., int to double) when performing operations. Q: How do you cast an integer 'x' to a double? A: Use static_cast(x). Flashcard Set 4: Branching in C++ Q: What is the purpose of an 'if' statement in C++? A: To execute a block of code only if a specified condition is true. Q: What is the syntax for an 'if-else' statement? A: if (condition) { // code if true } else { // code if false } Q: How does an 'if-elseif-else' structure work? A: It evaluates conditions sequentially until one is true. If none are true, it executes the code in the else block. Flashcard Set 5: Input and Output in C++ Q: How do you get input from the user in C++? A: Using 'cin', e.g., cin >> variable;. Q: How do you output data in C++? A: Using 'cout', e.g., cout