CS 110 Final Study Guide 2018 PDF

Title CS 110 Final Study Guide 2018
Author Jacob Chapman
Course Programming and Problem Solving
Institution University of Regina
Pages 12
File Size 155.6 KB
File Type PDF
Total Downloads 90
Total Views 154

Summary

This doc covers every topic discussed in CS 110....


Description

CS 110 FINAL Study Guide 2018 : 1. Basic header file at the top of any programming code: - #include 2. Is a mechanism to avoid naming conflicts in a large program (written below libraries): - using namespace std; 3. How to execute the main function of the program? - Int main() 4. Is placed at the end of every main function to exit the program: - Return 0; 5. Special character used with functions: - Opening and closing parentheses - () 6. Denotes a block to enclose statements: - Opening and closing braces - { - } 7. Precedes a comment line: - Double slashes - // 8. Outputs to the console: - Stream insertion operator - >” 21. What are variables used for? - To store values used later inside the program 22. If variables are of the same datatype, how do you declare more than one? - Separate them by commas 23. Do variables ofen have initial values? - Yes 24. In C++, what is the equals sign (=) used for? - Its used as the assignment operator - Variable = expression 25. Whats a constant in C++? - A value that never changes in the program 26. How to declare a constant? - Write const before the datatype - const datatype CONSTANTNAME = value; 27. benefits of using constants? - Don’t have to repeatedly change value - If it needs to be changed, it only has to be done once 28. Syntax for addition? - Plus sign (+)

29. Syntax for subtraction? - Minus sign (-) 30. Syntax for multiplication? - Little star (*) 31. Syntax for division? - Backslash (/) 32. Syntax for modulus? - Percent sign (%) 33. What do you need to be careful about when applying division in a program? - To add .0 to a number 34. What does an augmented assignment operator do? - Performs operation last afer all other operations are done 35. Syntax for increment operators: - For example, lets say you have int I = 3; - Use i++; - Now its 4 - Same for “I - -“ but it decreases 36. Can you put ++ or - - behind the variable? - Yes 37. What happens when you put increment or decrement behind variable? - That new value is used in the operation 38. What are selection statements? - Boolean expressions 39. Whats a Boolean expression? - It evaluates to a Boolean value that can either be true or false 40. How many comparison operators are there? - 6 41. Syntax for less than sign: - < 42. syntax for less than or equal to sign: - 44. syntax for greater than or equal to sign: - >= 45. syntax for equal to sign: - == 46. syntax for not equal to sign: - != 47. A variable that holds a Boolean is value is known as what? - Boolean variable 48. How does C++ represent true? - 1

49. How does C++ represent false? - 0 50. A one way if statement executes an action if and only if what? - The condition is true 51. How to draw flowcharts: - Start with diamond box, that contains the Boolean condition - Below, a rectangle box is drawn to represent the statements - Use arrows to connect the boxes 52. Are Boolean expressions enclosed in parentheses? - Yes 53. Do you add a semicolon at the end of a Boolean expression? - No 54. Specifies different actions whether its true or false: - Two way if else statement 55. Should you use braces to enclose statements in if statements? - Yes 56. What Boolean operator negates true to false and false to true? - The “not” operator - ! 57. What Boolean operator is TRUE if and only if both other operators are true? - The “and” operator - && 58. What Boolean operator is TRUE if at least one of the operands is true? - The “or” operator - || 59. What is the equation to determine a leap year? - Leapyear = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0) 60. What kind of statement executes statements based on the value of a variable or an expression? - Switch statement 61. What kind of rules must a switch statement observe? - Must yield an integral value and must be enclosed by parentheses - Must be integers -

When the value in a case statement matches the value of the switch-expression, the statements starting from this case are executed until either a break statement or the end of the switch statement is reached.

62. Whats a default case in a switch statement? - Its optional and it executes a statement if nothing else happens 63. What keyword in a switch statement is optional? - Break 64. What does a break statement do? - Ends the switch statement

65. What kind of expression evaluates an expression based on a condition? - Conditional expression 66. How do conditional expressions work? - The result is “expression1” if “Boolean expression” is true; otherwise its “expression 2”. 67. Syntax for conditional expressions: - Boolean-expression ? expression1 : expression2; 68. What header is used for trig functions? - 69. Syntax for trig functions in radians? - Sin(radians) - Cos(radians) - Tan(radians) - Obviously you have to input values 70. Syntax for inverse trig functions? - Asin(a) - Acos(a) - Atan(a) 71. Syntax for e raised to power of x: - Exp(x) 72. Syntax for natural logarithm of x: - Log(x) 73. Syntax for base 10 logarithm of x: - Log10(x) 74. Syntax for a raised to power of b: - Pow(a, b) 75. Syntax for square root of x: - Sqrt(x) 76. Syntax for rounding functions: - Ceil(x) rounds x up to nearest integer - Floor(x) rounds x down to nearest integer 77. This data type represents a single character? - Character data type 78. Syntax for character data type? - Char 79. A character literal is enclosed by what? - Single quotation marks 80. Character ‘0’ to ‘9’ are what in ASCII code? - 48 to 57 81. Characters ‘A’ to ‘Z’ are what in ASCII code? - 65 to 90 82. Characters ‘a’ to ‘z’ are what in ASCII code? - 97 to 122

83. What are escape sequences? - They are notations to represent special characters 84. Syntax for backspace? - \b 85. ASCII code for backspace? - 8 86. Syntax for Tab? - \t 87. ASCII code for tab? - 9 88. syntax for new line? - \n 89. ASCII code for newline? - 10 90. Syntax for Form feed? - \f 91. ASCII code for form feed? - 12 92. syntax for carriage return? - \r 93. ASCII code for carriage return? - 13 94. Syntax for backslash: - \\ 95. ASCII code for backslash? - 92 96. Syntax for double quote: - \” 97. ASCII code for double quote: - 34 98. What happens when a float (or double) value Is casted into a char? - The float value is casted into an integer and then into a char 99. What happens when a char is casted into a numeric type? - Its ASCII code value its casted into a specific numeric type 100. Is a sequence of characters? - String 101. What header file do you need to include to use the string datatype? -

102. What type is the string? - An object type 103. What are the simple functions for a string? - Length - Size - At 104. What function returns the number of characters in a string? - Length() - Size() 105. What function returns the character at a specific index in the string? - At(index) 106. To write a program that displays a city with more than one word, how would you go about it? - Use getline(cin, s) 107. What in C++ provides additional functions for formatting how a value is displayed? - Stream manipulators 108. Sets the precision of a floating point number? - Setprecision(n) 109. Displays floating-point numbers in a fixed position? - Fixed 110. Causes a floating point numbr to be displayed with a decimal point with trailing zeroes? - Showpoint 111. How to write data to a file? - First declare a variable of the ofstream datatype 112. How to open a file? - Invoke the open function from output object - Output.open(“file.txt”) 113. How to close a file? - Output.close() - Input.close()

114. How to read data from a file? - Use ifstream input; 115. How to specify a file? - Use ifstream input(“file.txt”) 116. Executes statements repeatedly while the condition is true: - The while loop 117. Syntax for the while loop? - While (Loop – continuation – condition) 118. How to read all data from a file in a loop? - Use eof() function in while loop 119. This type of loop executes the loop body first, then checks the loop continuation condition: - Do while loop 120. Syntax for do while loop? - Do - { - // Loop body; - statements; - } while ( ); 121. Has a concise syntax for writing loops: - The for loop 122. Syntax for the “for loop”: - For (I = initialvalue; I < endvalue; i++) - { - …… - }

Continuation from midterm for FINAL… FUNCTIONS 1. Is a collection of statements grouped together to perform an operation: - A function 2. A function definition consists of? - Function name - Parameters - Return value type - Body 3. Syntax for defining a function? - Returnvaluetype functionname(list of parameters) 4. In an int function, what do you return? - A value 5. Having an & sign in the parameter list, what does that do? - Also returns the result back to the main function 6. What type of function doesn’t return a value? - A void function 7. The variables declared in a function header are known as? - Formal parameters 8. When a function is invoked, you pass what? - The actual parameters 9. The function exits when what is used? - The return statement is used 10. A function must be what before it is invoked? - Defined 11. A return statement is not needed for a void function but can be used to do what? - Terminate the function and return control to the functions caller 12. Algorithm to find GCD: - While (k … etc

13. How to test if a file exists when reading data from a file? - If (input.fail()) - { cout number; if (input.eof()) break; cout...


Similar Free PDFs