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.
W11_Programming_Qs-1
Due on 2023-04-13, 23:59 IST
Consider the following program (in C++11).
• Fill in the blanks at LINE-1 and LINE-3 with appropriate template definitions.
• Fill in the blanks at LINE-2 and LINE-4 with appropriate parameters for findMax function.
The program must satisfy the sample input and output.
Solution :
#include <iostream>
#include <type_traits>
#include <utility>
template<typename T>
T findMax(T num){
return num;
}
template<typename T1, typename T2, typename... Args>
auto findMax(T1 num1, T2 num2, Args... nums) -> typename std::common_type<T1, T2, Args...>::type {
auto max = findMax(num2, nums...);
return num1 >= max ? num1 : max;
} |
W11_Programming_Qs-2
Due on 2023-04-13, 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 declaration for the function wrapper.
• Fill in the blank at LINE-2 with an appropriate header for function wrapper.
• Fill in the blank at LINE-3 with an appropriate return statement for function wrapper.
The program must satisfy the sample input and output. Solution :
template<typename T, typename U, typename V>
double wrapper(std::ostream& os, V&& f, T&& v1, U&& v2){
return f(os, std::forward<T>(v1), std::forward<U>(v2));
} |
W11_Programming_Qs-3
Due on 2023-04-13, 23:59 IST
Consider the following program (in C++11) to find factorials of 3 integers. Fill in the blanks
as per the instructions given below:
• Fill in the blank at LINE-1 to complete the λ function for computing factorial.
• Fill in the blank at LINE-2 to complete the λ function for printing the vector v2.
The program must satisfy the sample input and output.
Solution :
std::function<long long(int)> fact = [&](int n) { //LINE-1
return n > 1 ? n * fact(n - 1) : 1;
};
for(auto i : v1)
v2.push_back(fact(i));
// Lambda function to print vector v2
std::function<void(const std::vector<long long>&)> print_vector = [&](const std::vector<long long>& x) { //LINE-2
for (auto i : x){ std::cout << i << " "; } };
print_vector(v2);
return 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 | Click Here |
| Assignment 12 | Click Here |
Comments
Post a Comment