Are you looking for the Answers to NPTEL Programming in Modern C++ Assignment 7? This article will help you with the answer to the National Programme on Technology Enhanced Learning (NPTEL) Course ” Programming in Modern C++ Assignment 5 “
What is Programming in Modern C++?
There has been a continual debate on which programming language/s to learn, to use. As the latest TIOBE Programming Community Index for August 2021 indicates – C (13%), Python (12%), C++ (7%), Java (10%), and C#(5%) together control nearly half the programming activities worldwide. Further, C Programming Language Family (C, C++, C#, Objective C etc.) dominate more than 25% of activities. Hence, learning C++ is important as one learns about the entire family, about Object-Oriented Programming and gets a solid foundation to also migrate to Java and Python as needed. C++ is the mother of most general purpose of languages. It is multi-paradigm encompassing procedural, object-oriented, generic, and even functional programming. C++ has primarily been the systems language till C++03 which punches efficiency of the code with the efficacy of OOP.
CRITERIA TO GET A CERTIFICATE
Average assignment score = 25% of the average of 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 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.
Below you can find the answers for NPTEL Programming in Modern C++ Assignment 7
NPTEL Programming in Modern C++ Assignment 7 Answers:-
Q1. Consider the following program. Fill in the blanks at LINE-1, 2, and 3 with appropriate inheritance statement
Code:-
class D1 : virtual public Base { // LINE-1 : Inherit from class Base
public:
D1(int x = 0) : Base(x+1) { fun(x+1); }
};
class D2 : virtual public Base { // LINE-2 : Inherit from class Base
public:
D2(int x = 0) : Base(x+2) { fun(x+2); }
};
class DD : public D1, public D2 { // LINE-3 : Inherit from class D1 and D2
public:
DD(int i = 0) : D1(i*2), D2(++i) { fun(i); }
};
For Online programming test help and final exam preparation material Click Me
Q2. Consider the following program. Fill in the blanks at LINE-1 and 2 with appropriate cast statement,
Code:-
try{
Base& ra1 = static_cast<Base&>(d); //LINE-1
ra1.f(x);
Derived& rb1 = static_cast<Derived&>(b); //LINE-2
rb1.f(x);
}
Next Week Answers: Assignment 08
Q3. Consider the following program. Fill in the blanks at LINE-1 and 2 with appropriate casting operator such that it will satisfy the given test cases.
Code:-
void fun(const A &t){
int x;
cin >> x;
A &u = const_cast<A &>(t); //LINE-1
u.print();
B &v = reinterpret_cast<B &>(u); //LINE-2
v = x;
v.print();
}
For other courses answers:- Visit
For Internship and job updates:- Visit