🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

CIS-1101-Midterm-Reviewer.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

CIS 1101 Midterm Reviewer Edwin Bartlett --------------------- Part 1 --------------------- B. Pointers C. Structures 1. Who developed the C programming D. Arrays language?...

CIS 1101 Midterm Reviewer Edwin Bartlett --------------------- Part 1 --------------------- B. Pointers C. Structures 1. Who developed the C programming D. Arrays language? 6. What is the primary purpose of functions A. Alan Turing in C? B. Dennis Ritchie C. Bjarne Stroustrup A. To declare variables D. Linus Torvalds B. To organize code into reusable blocks 2. What is the primary purpose of the C. To perform input/output operations #include directive in C? D. To create new data types A. Defines a new data type 7. Which of the following is a standard B. Declares a function library function in C? C. Includes the standard input/output library A. myFunction() D. Creates a new variable B. scanf() C. customPrint() 3. Which of the following is the correct D. userDefined() syntax for a basic C program structure? 8. What is the entry point of a C program? A. int main(void) {... } B. void main() {... } A. main() function C. program main() {... } B. start() function D. main() int {... } C. program() function D. initialize() function 4. What is the output of the following C code? 9. Which component of a C program is used to include header files? C/C++ printf("Hello, World!\n"); A. Directives B. Global variables C. Functions A. Hello, World! D. Main function B. World, Hello! 10. Where are global variables declared in a C. No output C program? D. An error message A. Inside a function 5. Which feature of C allows for direct B. Outside of any function manipulation of memory addresses? C. Within a block A. Functions D. In a separate file 1 CIS 1101 Midterm Reviewer Edwin Bartlett 11. What is the return type of the main() C. To provide function prototypes and function in C? type definitions D. To create new data types A. void B. int 16. How are headers included in a C program? C. char D. float A. Using the include keyword 12. Which component of a C program B. Using the import keyword contains the actual implementation of C. Using the define directive functions? D. Using the #include directive A. Function declarations 17. Which header file provides functions for B. Function definitions input/output operations? C. Directives D. Global variables A. stdio.h B. stdlib.h 13. How can command-line arguments be C. string.h passed to a C program? D. math.h A. By declaring them as global 18. Which header file is used for string variables manipulation? B. By using the scanf() function C. By modifying the main() function A. stdio.h signature B. stdlib.h D. By using the argc and argv C. string.h parameters in the main() function D. math.h 14. What is the significance of the return 19. Which header file provides functions for 0; statement in the main() function? mathematical calculations? A. Indicates an error occurred A. stdio.h B. Indicates successful program B. stdlib.h execution C. string.h C. Terminates the program abruptly D. math.h D. Returns the value of the last expression 20. What is the significance of including headers in a C program? 15. What is the purpose of headers in C programming? A. It makes the code more readable B. It allows the compiler to recognize A. To declare variables functions and variables B. To define functions 2 CIS 1101 Midterm Reviewer Edwin Bartlett C. It improves program performance B. == D. It prevents errors in the code C. + D. - 21. Which header file is commonly used for working with date and time? 26. Which control flow statement is used to execute a block of code repeatedly until a A. stdio.h condition is met? B. stdlib.h C. string.h A. if D. time.h B. for C. while 22. What is the purpose of a semicolon in D. switch C? 27. What is the importance of proper A. To declare a variable formatting and indentation in C code? B. To terminate a statement C. To start a new line A. It makes the code more efficient D. To define a function B. It improves code readability C. It prevents syntax errors 23. Which of the following is a valid data D. It increases program speed type in C? 28. Which of the following is a valid C A. integer statement? B. string C. boolean A. int x = 10; D. float B. if (x > 5) then {... } 24. What is the correct syntax for declaring C. for (i = 0; i < 10; i++); a function in C? D. while (x != 0) { x = x - 1; } A. function name(parameters) {... } 29. Syntax errors are identified by: B. void function A. The compiler name(parameters) {... } B. The debugger C. function name(parameters): C. The runtime environment return type {... } D. The programmer D. return type function name(parameters) {... } 30. Semantic errors occur when: 25. Which operator is used for assignment A. The code violates the syntax rules in C? B. The code produces unexpected behavior A. = C. The code is logically incorrect 3 CIS 1101 Midterm Reviewer Edwin Bartlett D. The code is not compiled B. var C. static 31. Logical errors are often caused by: D. final A. Incorrect syntax 37. Functions are used to: B. Incorrect semantics C. Incorrect logic or algorithm A. Store data D. All of the above B. Perform specific tasks C. Declare variables 32. Debugging techniques for identifying D. Define constants semantic errors include: 38. To call a function, you use its: A. Using print statements B. Stepping through the code with a A. Data type debugger B. Name C. Analyzing runtime behavior C. Value D. All of the above D. Constant 33. Division by zero is an example of: 39. Single-line comments in C start with: A. A syntax error A. // B. A semantic error B. D. Declare constants C. # and # D. / D. Declare constants C. # and # D. //* and //* 35. Which data type is commonly used for integers in C? 41. Commenting out code can be used to: A. float A. Temporarily disable code sections 22 CIS 1101 Midterm Reviewer Edwin Bartlett B. Permanently remove code 47. The data type used to store whole C. Replace code with comments numbers is: D. Improve code efficiency A. float 42. A variable declaration specifies: B. char C. int A. The variable's value D. double B. The variable's data type C. The variable's memory address 48. The data type used to store decimal D. The variable's name numbers with higher precision is: 43. Initialization of a variable is: A. float B. double A. Assigning a value to a variable after C. char declaration D. int B. Declaring a variable without assigning a value 49. The data type used to store single C. Using a variable in an expression characters is: D. Printing the value of a variable A. float 44. The assignment operator in C is: B. double C. char A. == D. int B. = C. := 50. The data type used to store smaller D. -> integer values is: 45. To print the value of a variable in C, you A. int can use: B. short C. long A. printf() D. double B. scanf() C. puts() 51. The format specifier for printing an D. cout integer value is: 46. A good naming convention for variables A. %f involves: B. %c C. %s A. Using reserved keywords D. %d B. Using short, cryptic names C. Using descriptive names 52. Reserved words in C are also known as: D. Using uppercase letters A. Identifiers B. Keywords 23 CIS 1101 Midterm Reviewer Edwin Bartlett C. Declarations 58. The format specifier for printing a D. Statements character is: 53. Reserved words cannot be used as: A. %d B. %f A. Variable names C. %c B. Function names D. %s C. Data types D. Comments 58. The format specifier for printing a floating-point number with two decimal 54. The keyword used to declare a constant places is: variable is: A. %d A. static B. %.2f B. const C. %c C. extern D. %s D. volatile 59. The escape sequence used to insert a 55. The keyword used to terminate the tab is: execution of a loop or switch statement is: A. \n A. break B. \t B. continue C. \r C. return D. \f D. goto 60. The escape sequence used to insert a --------------------- Part 2 --------------------- double quote is: 56. The function used to display output to A. \" the screen in C is: B. \' C. \\ A. print D. \b B. display C. write 61. The escape sequence used to insert a D. printf backslash is: 57. The character used to insert a newline A. \" in the output is: B. \' C. \\ A. \n D. \b B. \t C. \r 62. Placeholders are used to: D. \v A. Define variable names 24 CIS 1101 Midterm Reviewer Edwin Bartlett B. Specify data types 68. Operator precedence determines the: C. Insert variable values into input or output A. Order in which operators are D. Perform calculations evaluated B. Data types of variables 63. The format specifier for a string is: C. Number of operators in an expression A. %f D. Memory allocation for variables B. %c C. %d 69. Parentheses are used to: D. %s A. Change the order of operator 64. The function used to accept user input evaluation in C is: B. Declare variables C. End a statement A. printf D. Define functions B. scanf C. input 70. The basic assignment operator is: D. read A. = --------------------- Part 3 --------------------- B. += C. -= 65. The operator used for addition is: D. *= A. + 71. The operator used for addition B. - assignment is: C. * D. / A. = B. += 66. The operator used for modulus C. -= (remainder) is: D. *= A. + 72. The operator used for subtraction B. - assignment is: C. * D. % A. = B. += 67. The operator used for incrementing a C. -= variable by 1 is: D. *= A. ++ 73. The operator used for multiplication B. -- assignment is: C. += D. -= A. = 25 CIS 1101 Midterm Reviewer Edwin Bartlett B. += A. (int) C. -= B. (float) D. *= C. (char) D. (double) 74. The operator used for modulus assignment is: 80. The operator with the highest precedence is: A. = B. += A. + C. -= B. - D. %= C. * D. () 75. Typecasting refers to the process of: 81. The associativity of the assignment A. Creating new data types operator (=) is: B. Converting values from one data type to another A. Left to right C. Performing arithmetic operations B. Right to left D. Defining functions C. Both left to right and right to left D. None of the above 76. Implicit typecasting is performed: 82. If two operators have the same A. Manually by the programmer precedence, their associativity determines: B. Automatically by the compiler C. Only for integer values A. The order in which they are D. Only for floating-point values evaluated B. The data type of the result 77. The syntax for explicit typecasting is: C. The memory allocation for the result D. None of the above A. (desired_type)value B. value(desired_type) --------------------- Part 4 --------------------- C. type(value) D. value type 83. The function used to check if a character is alphabetic is: 78. When casting from a wider data type to a narrower data type, there is a risk of: A. isalpha B. isdigit A. Data loss C. isupper B. Overflow D. islower C. Underflow D. All of the above 84. The function used to check if a character is a digit is: 79. The typecast operator for converting a value to an integer is: A. isalpha 26 CIS 1101 Midterm Reviewer Edwin Bartlett B. isdigit 90. The function used to concatenate two C. isupper strings is: D. islower A. strlen 85. The function used to convert a B. strcpy character to uppercase is: C. strcat D. strcmp A. toupper B. tolower 91. The function used to compare two C. isupper strings is: D. islower A. strlen 86. The function used to check if a B. strcpy character is a control character is: C. strcat D. strcmp A. iscntrl B. isprint 92. The function used to search for a C. ispunct character in a string is: D. isxdigit A. strchr 87. The function used to check if a B. strstr character is a hexadecimal digit is: C. strcat D. strcmp A. iscntrl B. isprint 93. The function used to calculate the C. ispunct square root of a number is: D. isxdigit A. sqrt 88. The function used to determine the B. pow length of a string is: C. sin D. cos A. strlen B. strcpy 94. The function used to raise a number to C. strcat a power is: D. strcmp A. sqrt 89. The function used to copy one string to B. pow another is: C. sin D. cos A. strlen B. strcpy 95. The function used to calculate the sine C. strcat of an angle is: D. strcmp A. sqrt 27 CIS 1101 Midterm Reviewer Edwin Bartlett B. pow 101. The return keyword is used to: C. sin D. cos A. Define a function B. Call a function 96. The function used to calculate the C. Exit a function and return a value cosine of an angle is: D. Declare a variable A. sqrt 102. A function prototype is used to: B. pow C. sin A. Define a function D. cos B. Call a function C. Provide a declaration before the --------------------- Part 5 --------------------- definition D. Return a value 97. Functions in C are used to: 103. Actual parameters are: A. Define data types B. Declare variables A. The variables declared in a function C. Perform specific tasks definition D. Create loops B. The values passed to a function when it is called 98. A function is defined by: C. The return type of a function D. The function name A. A name, return type, and parameters B. A variable declaration 104. When passing parameters by value: C. A conditional statement D. A loop A. A copy of the value is passed B. The original value is modified 99. To call a function, you: directly C. The function cannot access the A. Declare it original value B. Define it D. The function returns the modified C. Use its name with parentheses value D. Use a conditional statement 105. When passing parameters by 100. Formal parameters are: reference: A. The actual values passed to a A. A copy of the value is passed function B. The original value is modified B. The variables declared in a function directly definition C. The function cannot access the C. The return type of a function original value D. The function name D. The function returns the modified value 28 CIS 1101 Midterm Reviewer Edwin Bartlett 106. To pass a variable by reference in C, C. double you use: D. void A. The variable name 112. A function that does not require any B. The variable value arguments is defined with: C. The variable's memory address D. The variable's data type A. Empty parentheses () B. A void return type 107. The return keyword is used to: C. No function body D. A parameter list A. Define a function B. Call a function 113. A function that performs a task C. Exit a function and return a value without requiring any input can be defined D. Declare a variable as: 108. To return an integer value from a A. A void function function, the return type should be: B. A parameterless function C. Both A and B A. int D. Neither A nor B B. char C. double 114. Consider the following function: D. void C/C++ 109. To return a floating-point value from a function, the return type should be: void printMessage() { printf("Hello, A. int world!\n"); B. char } C. double D. void What is the return type of this function? 110. To return a character value from a function, the return type should be: A. int B. char A. int C. double B. char D. void C. double D. void 115. Consider the following function: 111. If a function does not need to return C/C++ any value, the return type should be: int calculateSum() { A. int int x = 5, y = 10; B. char 29 CIS 1101 Midterm Reviewer Edwin Bartlett return x + y; int randomNum = } getRandomNumber(); printf("Random number: %d\n", randomNum); return 0; What is the return type of this function? } A. int B. char What is the output of the above code? C. double D. void A. A random integer between 0 and 99 B. Always 0 116. Consider the following function: C. Always 100 D. The code has an error C/C++ char generateRandomLetter() 118. Consider the following code: { return 'A' + rand() % C/C++ 26; double calculatePi() { } return 3.14159; } What is the return type of this function? int main() { A. int double piValue = B. char calculatePi(); C. double printf("Value of pi: D. void %f\n", piValue); return 0; 117. Consider the following code: } C/C++ int getRandomNumber() { What is the output of the above code? return rand() % 100; A. 0 } B. The code has an error C. Value of pi: 3.14159 int main() { D. A random value 30 CIS 1101 Midterm Reviewer Edwin Bartlett 119. To call a function that returns a value, B. Only the function in which they are you: declared C. Functions within the same file A. Assign the returned value to a D. None of the above variable B. Use the function name only 125. A recursive function is a function that: C. Use the function name with parentheses and arguments A. Calls itself directly or indirectly D. Use the function name with B. Does not have a return type parentheses but no arguments C. Has only one parameter D. Uses a loop 120. Local variables are declared: 126. The base case of a recursive function A. Outside of any function is: B. Inside a function C. At the beginning of a program A. The simplest case that can be D. In a separate file solved directly B. The most complex case 121. Global variables are declared: C. The recursive case D. The function call A. Outside of any function B. Inside a function 127. Recursive functions are often used C. At the beginning of a program for: D. In a separate file A. Solving problems that can be broken 122. The scope of a local variable is: down into smaller, similar subproblems A. Global B. Performing iterative tasks B. Function-specific C. Defining global variables C. Program-wide D. Creating loops D. Block-specific 128. Compared to iterative solutions, 123. The scope of a global variable is: recursive solutions are generally: A. Global A. More efficient B. Function-specific B. Less memory-efficient C. Program-wide C. More complex to understand D. Block-specific D. All of the above 124. Global variables can be accessed Note: Recursive solutions tend to be less from: memory efficient than iterative solutions because they involve function calls, which A. Any function in the program create a stack frame for each call. This stack frame stores information about the function's 31 CIS 1101 Midterm Reviewer Edwin Bartlett parameters, local variables, and return D. Create loops address. As the recursion depth increases, the stack grows, consuming more memory. 131. The if statement executes a code block if: 129. Consider the following code: A. The condition is true B. The condition is false C/C++ C. The condition is undefined int factorial(int n) { D. The condition is always true if (n == 0) { return 1; 132. The else statement is used: } else { A. To execute code if the if condition is return n * true factorial(n - 1); B. To execute code if the if condition is } false } C. To define a new variable D. To create a loop int main() { int num = 5; 133. The switch statement is used: int result = A. To execute different code blocks factorial(num); based on the value of an expression printf("Factorial of %d B. To define a loop is: %d\n", num, result); C. To declare variables D. To perform calculations return 0; 134. The break statement is used in a } switch statement to: A. Exit the switch statement What is the output of the above code? B. Continue to the next case C. Define a new case A. 0 D. Perform a calculation B. 5 C. 25 135. The operator used to check if two D. 120 values are equal is: --------------------- Part 6 --------------------- A. == 130. Conditional statements are used to: B. != C. > A. Define variables D. < B. Perform calculations C. Make decisions 32 CIS 1101 Midterm Reviewer Edwin Bartlett 136. The operator used to check if two D. Neither operand is true values are not equal is: 142. Short-circuit evaluation means that: A. == B. != A. Both operands of a logical operator C. > are always evaluated D. < B. The second operand of a logical operator is not evaluated if the 137. The operator used to check if the left outcome can be determined by the operand is greater than the right operand first operand is: C. The first operand of a logical operator is not evaluated A. == D. The logical operators are evaluated B. != from right to left C. > D. < 143. The expression (x > 0 && y / x > 2) will evaluate to true if: 138. The operator used to check if the left operand is less than the right operand is: A. Both x and y are greater than 0 B. x is greater than 0 and y / x is A. == greater than 2 B. != C. x is greater than 0 or y / x is greater C. > than 2 D. < D. Neither x nor y is greater than 0 139. The AND operator (&&) returns true if: 144. The condition in an if statement must evaluate to: A. Both operands are true B. At least one operand is true A. A number C. Neither operand is true B. A character D. The first operand is true C. A string D. True or false 140.The OR operator (||) returns true if: Note: Remember that even if the logical A. Both operands are true value is true or false, the actual value would B. At least one operand is true always be numeric (0 for false and non-zero C. Neither operand is true integer for true). Negative integers are also D. The first operand is true evaluated as true, since they are non-zero. 141. The NOT operator (!) returns true if: 145. If the condition in an if statement is A. The operand is true true, the code block within the curly braces B. The operand is false is: C. Both operands are true 33 CIS 1101 Midterm Reviewer Edwin Bartlett A. Executed B. Continue to the next case B. Skipped C. Execute the default case C. Repeated D. None of the above D. Ignored 151. The switch statement is used to: 146. Nested if statements can be used to: A. Declare variables A. Create more complex B. Perform calculations decision-making structures C. Make decisions based on multiple B. Declare variables cases C. Perform calculations D. Create loops D. Create loops 152. The expression in a switch statement 147. The else statement is used to: is evaluated against: A. Execute code if the if condition is A. The default case true B. The case labels B. Execute code if the if condition is C. The break statements false D. The curly braces C. Declare a new variable D. Create a loop 153. The default label in a switch statement is used to: 148. The if...else if...else statement is used to: A. Define the default case B. Exit the switch statement A. Declare variables C. Continue to the next case B. Perform calculations D. None of the above C. Make decisions based on multiple conditions 149. Consider the following code segment: D. Create loops C/C++ 149. The else if clause is executed when: int x = 10; A. The previous if or else if condition is true if (x > 0) { B. The previous if or else if condition is printf("x is false positive\n"); C. The if condition is true } else { D. The if condition is false printf("x is negative or zero\n"); 150. The break statement is used in a switch statement to: } A. Exit the switch statement 34 CIS 1101 Midterm Reviewer Edwin Bartlett What is the output of the code? A. x is negative or zero B. x is positive printf("Tuesday\n"); C. The code has an error break; D. None of the above case 3: 150. Consider the following code segment: printf("Wednesday\n"); break; C/C++ default: int age = 18; printf("Invalid day\n"); if (age >= 18) { printf("You are an } adult\n"); } else { printf("You are a What is the output of the code? minor\n"); } A. Monday B. Tuesday C. Wednesday What is the output of the code? D. Invalid day A. You are an adult 152. Consider the following code segment: B. You are a minor C. The code has an error C/C++ D. None of the above char grade = 'B'; 151. Consider the following code segment: switch (grade) { case 'A': C/C++ int day = 3; printf("Excellent\n"); break; switch (day) { case 'B': case 1: printf("Good\n"); printf("Monday\n"); break; break; case 'C': case 2: printf("Average\n"); 35 CIS 1101 Midterm Reviewer Edwin Bartlett break; default: printf("Fail\n"); } What is the output of the code? A. Excellent B. Good C. Average D. Fail 153. Consider the following code segment: C/C++ int num = 5; switch (num % 2) { case 0: printf("Even\n"); break; default: printf("Odd\n"); } What is the output of the code? A. Even B. Odd C. The code has an error D. None of the above ---------------------- End ---------------------- 36

Use Quizgecko on...
Browser
Browser