What is Programming in Modern C++?
This course introduces problem-solving and programming using the C++ programming language. The topics include:
- Basic programming notions. Control flow, variables, and assignments statements, conditional execution, looping, function calls including recursion. Arrays and structures. Elementary aspects of classes. Heap memory.
- Program design. How human beings solve problems manually. Strategies for translating manual techniques to computer programs. Organizing large programs into units such as functions and classes. Introduction to assertions and invariants.
- Programming applications. Arithmetic on polynomials, and matrices. Root finding. Sorting and searching. Design of editors and simulators, including graphical editors. Elementary animation. A rudimentary graphics system will be discussed.
- Standard Library of C++. The string, vector, and map classes.
W12_Programming_Qs-1
Due on 2023-04-20, 23:59 IST
Consider the program below (in C++11), which implements a smart pointer.
• Fill in the blank at LINE-1 with appropriate header and initializer list for the copy constrcutor.
• Fill in the blank at LINE-2 with appropriate header to overload dereferenceing operator.
• Fill in the blank at LINE-3 with appropriate header to overload indirection operator.
The program must satisfy the given test cases.
Solution :
template <typename T>
class SmartPtr {
public:
explicit SmartPtr(T* pointee) : pointee_(pointee) { }
SmartPtr(const SmartPtr& other) : pointee_(other.pointee_) { } // LINE-1: copy constructor
~SmartPtr() { if(pointee_ != nullptr) delete pointee_; }
T& operator*() { return *pointee_; } // LINE-2: Dereferencing
T* operator->() { return pointee_; } // LINE-3: Indirection
private:
T* pointee_;
}; |
W12_Programming_Qs-2
Due on 2023-04-20, 23:59 IST
Consider the following program in C++14 to represent a doubly linked list (of generic type),
which allows adding items at the front of the list. Complete the program as per the instructions
given below.
• Fill in the blank at LINE-1 with appropriate statements to traverse the list in forward direction.
• fill in the blank at LINE-2 with appropriate statements to traverse the list in backward direction,
The program must satisfy the sample input and output.
Solution :
void biTraverse(){
for(auto t = first; t != nullptr; t = t->next)
std::cout << t->info << " ";
std::cout << std::endl;
for(auto p = last; p != nullptr; p = p->prev.lock())
std::cout << p->info << " ";
}
private:
std::shared_ptr<node<T>> first = nullptr;
std::shared_ptr<node<T>> last = nullptr;
};
W12_Programming_Qs-3Due on 2023-04-20, 23:59 IST Consider the following program (in C++11). • Fill in the blank at LINE-1 by defining a mutex object. • Fill the blanks at LINE-2 and LINE-4 by locking the mutex object. • Fill the blanks at LINE-3 and LINE-5 by unlocking the mutex object. The program must satisfy the sample input and output. Solution :
|
CRITERIA TO GET A CERTIFICATE
Average assignment score = 25% of the average of the best 8 assignments out of the total 12 assignments given in the course.
Exam score = 75% of the proctored certification exam score out of 100
Final score = Average assignment score + Exam score
YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF THE AVERAGE ASSIGNMENT SCORE >=10/25 AND THE EXAM SCORE >= 30/75. If one of the 2 criteria is not met, you will not get the certificate even if the Final score >= 40/100.
| An Introduction To Programming Through C++ | Answers |
| Assignment 1 | Click Here |
| Assignment 2 | Click Here |
| Assignment 3 | Click Here |
| Assignment 4 | Click Here |
| Assignment 5 | Click Here |
| Assignment 6 | Click Here |
| Assignment 7 | Click Here |
| Assignment 8 | Click Here |
| Assignment 9 | Click Here |
| Assignment 10 | Click Here |
| Assignment 11 | Click Here |
| Assignment 12 | Click Here |
Comments
Post a Comment