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.
W10_Programming_Qs-1
Due on 2023-04-06, 23:59 IST
Consider the following program (in C++11).
• Fill in the blank at LINE-1 with appropriate header for overloading copy assignment
operator.
• Fill in the blank at LINE-2 with appropriate header and initialization list for move
constructor.
• Fill in the blank at LINE-3 with appropriate header for overloading move assignment
operator.
Solution :
#include <iostream>
#include <vector>
class item {
public:
item() : cp_(nullptr) { }
item(char c) : cp_(new char(c)) { }
item& operator=(const item& ob) { // LINE-1: copy assignment
if (this != &ob) {
delete cp_;
cp_ = new char(*(ob.cp_) + 1);
}
return *this;
}
item(item&& ob) : cp_(nullptr) { // LINE-2: move constructor
std::swap(cp_, ob.cp_);
}
item& operator=(item&& ob) { // LINE-3: move assignment
if (this != &ob) {
delete cp_;
cp_ = ob.cp_;
ob.cp_ = nullptr;
}
return *this;
} |
W10_Programming_Qs-2
Due on 2023-04-06, 23:59 IST
Consider the following program (in C++11). Fill in the blanks as per the instructions given
below:
• Fill in the blanks at LINE-1 and LINE-2 with appropriate headers for the definition of
function getValue() belongs to class Gram and class KiloGram.
• Fill in the blank at LINE-3 with appropriate template definition.
• Fill in the blank at LINE-4 with appropriate header for function convert_weight.
Solution :
Coming SOON !!!!! |
W10_Programming_Qs-3
Due on 2023-04-06, 23:59 IST
Consider the following program (in C++11). Fill in the blanks as per the instructions given
below:
• Fill in the blank at LINE-1 with an appropriate template definition.
• Fill in the blank at LINE-2 to complete the header for function inner_product.
• Fill in the blank at LINE-3 to define the new type Tmp.
The program must satisfy the sample input and output.
Solution :
#include <iostream>
#include <vector>
template<typename T1, typename T2>
void inner_product(const std::vector<T1>& v1, const std::vector<T2>& v2) {
typedef typename std::common_type<T1, T2>::type Tmp; // LINE-3: define new type Tmp
/* Don't edit the following part */
Tmp sum = 0; |
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 | NA |
| Assignment 12 | NA |
Comments
Post a Comment