NPTEL Programming in Modern C++ Week 2 Assignment Answers 2025
1. Consider the following function prototypes of function add().
P1: int add(int n1 = 0, int n2) ;
P2: int add(int = 0, int = 0) ;
P3: double add(double = 0, double d = 0.0) ;
P4: double add(int = 0, double d = 0.0) ;
P5: double add(int n1 = 0, int n2, double n3 = 0) ;
Which of the following sets consists of all valid prototypes of function add()?
a) {P1, P3}
b) {P2, P3, P4}
c) {P1, P2, P3, P4}
d) {P2, P3, P5}
Answer :- For Answers Click Here
2. Consider the following function prototypes of function add().
P1: int add(int n1);
P2: int add(int = 0, int = 0) ;
P3: double add (int = 0, double d = 0.0) ;
P4: int add (int = 0, double d = 0.0);
P5: double add (int n1 = 0, int n2 = 0, double n3 = 0) ;
Which of the above pairs of the prototypes is ambiguous and illegal as per the rule of function
overloading?
a) P1, P2
b) P2, P3
c) P3, P4
d) P2, PS
Answer :-
3.

Answer :-
4.
Answer :-
5.

Answer :-
6.
Answer :- For Answers Click Here
7.
Answer :-
8.

Answer :-
9. Consider the following statement in C.
int *ip = (int *)malloc(sizeof(int)* 5);
Among the given options below, identily the equivalent statement/s (perform the same task)
in C++.
a) int *ip = new int (5) ;
b) int *ip = new int[5J;
c) int *ip = (int *)operator new(sizeof (int) * 5);
d) int *ip = (int *operator new (sizeof (int)) [5] ;
Answer :- For Answers Click Here