CS201 – Introduction to Programming (Subjective Fast-Learning)
8 High-Yield Subjective Prompts · High-yield C++ subjective fast-prep covering pointers, dynamic memory allocation, file pointers (seekg/tellg), constructors, destructors, operator overloading, and templates.
High-Yield Subjective Topics
- [3 Marks] Differentiate between Call by Value, Call by Pointer, and Call by Reference in C++ with how each affects original variables.
- [3 Marks] What is the difference between malloc() and calloc() in C/C++, and what problem occurs if dynamically allocated memory is not deallocated?
- [2 Marks] Why is seekg(0, ios::end) called before tellg() when determining the length of a file in C++?
- [5 Marks] Write a C++ program that opens a file data.txt in read/write mode (or writes A–Z characters to a file using a loop) and displays its contents safely.
- [3 Marks] Explain the roles of Default Constructor, Copy Constructor, and Destructor in a C++ class, and state what happens when a constructor is omitted.
- [3 Marks] Why can an expression like obj2 = 10 + obj1 NOT be implemented solely as a member operator function of obj1, and how do we solve it?
- [5 Marks] Write a C++ Function Template sumDisplay(T x, T y) that accepts values of any numeric type and prints their sum, plus trace sample calls for int and double.
- [2 Marks] What are stream manipulators (e.g., setw, setprecision, fixed) in C++ and when are they useful in formatted output?