COSC 1436: Programming Fundamentals - Final Exam Prep with 200 MCQs & Answers (2023/2024)
4 views 0 purchase
Course
COSC 1436
Institution
COSC 1436
COSC 1436: Programming Fundamentals - Final Exam Prep with 200 MCQs & Answers (2023/2024)
Conquer Your COSC 1436 Final Exam with Confidence!
Are you a student grappling with the complexities of COSC 1436: Programming Fundamentals? Preparing for your final exam can be daunting, but this compr...
1. What is the output of the following C++ code snippet?
C++
int x = 5;
int y = 10;
cout << "The sum is: " << x + y << endl;
a) The sum is: 510
b) The sum is: 15
c) The sum is: x + y
d) Error
2. Which of the following is NOT a valid C++ data type?
a) int
b) double
c) char
d) string (Note: string is part of the standard library, not a built-in data type)
3. What is the purpose of the #include <iostream> preprocessor directive?
a) To define constants
b) To provide access to input/output stream objects like cout and cin
c) To declare variables
d) To create functions
4. Which loop is most suitable when you know the exact number of iterations in advance?
a) while loop
b) do-while loop
c) for loop
, d) switch statement
5. What is the value of x after the following code executes?
C++
int x = 10;
x += 5;
a) 5
b) 10
c) 15
d) 50
6. Which of the following is used to get a single character from the user?
a) cin >>
b) getline()
c) cin.get()
d) cin.ignore()
7. What is the purpose of the if statement in C++?
a) To repeat a block of code a certain number of times
b) To execute a block of code only if a certain condition is true
c) To define a function
d) To declare a variable
8. Which of the following is an example of a logical operator in C++?
a) +
b) -
c) *
d) && (AND operator)
9. What is the difference between = and == in C++?
, a) They are the same.
b) = is used for comparison, == is used for assignment
c) = is used for assignment, == is used for comparison
d) None of the above
10. What will be the output of the following C++ code?
C++
int num = 10;
if (num > 5) {
cout << "Greater than 5" << endl;
} else {
cout << "Less than or equal to 5" << endl;
}
a) Less than or equal to 5
b) Greater than 5
c) No output
d) Error
11. Which of the following is a valid way to declare and initialize an array in C++?
a) int myArray[];
b) int myArray[5] = {1, 2, 3, 4, 5};
c) int myArray = {1, 2, 3};
d) int myArray[3] = {1, 2, 3, 4};
12. What is the index of the first element in a C++ array?
a) 1
b) 0
c) -1
, d) It depends on the array size
13. Which of the following is used to pass an array to a function in C++?
a) The array name
b) The array size
c) Both the array name and size
d) None of the above
14. What is the output of the following C++ code snippet?
C++
int numbers[3] = {5, 10, 15};
cout << numbers[1];
a) 5
b) 10
c) 15
d) Error
15. Which of the following sorting algorithms has the best average-case time complexity?
a) Bubble sort
b) Insertion sort
c) Merge sort
d) Selection sort
16. What is the output of the following C++ code?
C++
int a = 5;
int b = 3;
int c = a / b;
cout << c;
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller TheStudyOwl. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $3.99. You're not tied to anything after your purchase.