Programming In Modern C++ Assignment 1 Answers 2022

In this post, We have provided answers of NPTEL Programming In Modern C++ Assignment 1. We provided answers here only for reference. Plz, do your assignment at your own knowledge.

NPTEL Programming In Modern C++ Assignment 1 Answers 2022

1. Consider the following program.

What will be the output?


#include <iostream>
#include <cstring>
#include <stack>
using namespace std;
int main){
char str[10] COMPUTER";
stack<char> sl, s2;
for (i 0; i < strlen (str) /2; itt)
s1.push (str [i]) ;
for(; i < strlen(str); itt)
s2.push (str [i]);
while (!s1.cmpty ()) t
s2.push (s1. top()); s1.pop ();
while (Is2.ompty ())
cout (); s2.pop);
roturn 0;
Answer:- d

2. Which of the following is NOT a container adapter?

a) stack
b) queue
c) deque
d) priority-queue

Answer:- c

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW

Programming In Modern C++ Assignment 1 Answers 2022

3. Consider the following code segment.

Identily the appropriate option/s to fill in the blank LINE-1 such that output becomes found.

a) &data [01, kdata[5], key
b) dala, data+5, key
c) data, key, data+5
d) &data [O1, &key, &data [5]

#include <iostream>
#include <algorithm>
using namespace std;
int main() {
char data = {'a', 'b', 'c', 'd', 'e'};
char key = 'd';
if (binary_search (.
cout << "found";
cout << "not found";
return ;
Answer:- a, b

4. What will be the output?

a) 1 2 3 4 5
b) 1 2 4 5 3
c) 4 5 1 2 3
d) 2 3 4 51

Answer:- b

5. What will be the output?

a) 10 20 30 20 40 60
b)-1 -1-1 10 20 30 20 40 60
c)-1 -1 -1 10 20 30 0 0 0 20 40 60
d) 10 20 30

Answer:- a

6. Fill in the blank at LINE-1 with appropriate option/s such that the output is: 40 10 10 20

a) remove (kiarr [0], &iarr [61, 50)
b) remove(&iarr [0], &iarr [51, 50)
c) remove (iarr, iarr + 6, 50
d) remove (iarr, iarr + 6, iarr [5])

Answer:- a, c

👇For Week 02 Assignment Answers👇

Programming In Modern C++ Assignment 1 Answers 2022

7. What will be the output?

a) 3 2 1 2 3
b) 1 2 3 21
c) 5 4 3 4 5
d) 5 4 3 21

Answer:- d

8. Choose the appropriate option to fill in the blank at LINE-1, such that the output of the code would be: Modern C+t.

a) stri + str2
b) strcat (str1, str2)
c) stri.append (str2)
d) str1. insert (str2)

Answer:- a, c

9. What will be the output?

a) 10 20 30 40 50
b) 10 30 40 50 20
c) 50 40 30 20 10
d) 50 40 30 10 20

Answer:- b

For More NPTEL Answers:- CLICK HERE

Join Our Telegram:- CLICK HERE

About 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.

Then, why should I learn it if my primary focus is on applications? This is where the recent updates of C++, namely, C++11 and several later offer excellent depths and flexibility for C++ that no language can match. These extensions attempt to alleviate some of the long-standing shortcomings for C++ including porous resource management, error-prone pointer handling, expression semantics, and better readability. The present course builds up on the knowledge of C programming and basic data structure (array, list, stack, queue etc.) to create a strong familiarity with C++98 / C++03. Besides the constructs, syntax and semantics of C++ (over C), we also focus on various idioms of C++ and attempt to go to depth with every C++ feature justifying and illustrating them with several examples and assignment problems. On the way, we illustrate various OOP concepts. The course also covers important advances in C++11 and later released features.


  • Week 1: Programming in C++ is Fun.
  • Week 2: C++ as Better C.
  • Week 3: OOP in C++.
  • Week 4: OOP in C++.
  • Week 5: Inheritance.
  • Week 6: Polymorphism.
  • Week 7: Type Casting.
  • Week 8: Exceptions and Templates.
  • Week 9: Streams and STL.
  • Week 10: Modern C++.
  • Week 11: Lambda and Concurrency.
  • Week 12: Move, Rvalue and STL Containers.


Average assignment score = 25% of 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 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.

Leave a Comment