NPTEL Programming in Modern C++ Assignment 1 Answers 2024

NPTEL Programming in Modern C++ Assignment 1 Answers 2024

Hello learners In this article we are going to discuss NPTEL Programming in Modern C++ Assignment 1 Answers. All the Answers provided below to help the students as a reference, You must submit your assignment with your own knowledge and use this article as reference only.

About the course:-

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.

NPTEL Programming in Modern C++ Assignment 1 Answers 2024:

1. Consider the following program

#include <iostream>
#include <cstring>
#include <stack>
using namespace std;
int main(O{
char str[10] = "COMPUTER";
stack<char> si, s2;
int i;
for(i = 0; i < strlen(str)/2; i++)
si.push(strlil);
for(; i < strlen(str); i++)
s2.push(strlil);
while (!si.empty()) {
s2.push(si.top()); si.pop();
}
while (!s2.empty()) {
cout << s2.top(); s2.pop();
}
return 0;
}
Answer :- Will update answers soon and update on our telegram channel so Join Click Here

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

Answer :-

3. Consider the following program?

#include <iostream>
#include <algorithm>
using namespace std;
int main() {
char datall = 1%a%;; "%, c’, 4%, %e’l;
char key = ’d’;
if(binary.search( .. ... . ... _-}) //LINE-1
cout << "found";
else
cout << "not found";
return 0;
}
Answer :- 

4. Consider the following program?

#include <iostream>
#include <algorithm>
using namespace std;
void modify(int *arr){
rotate(arr, arr + 3, arr + 5);
rotate(arr, arr + 2, arr + 4);
}
int main() {
int iarr[5];
for(int i = 0; i < 5; i++)
*(iarr + 1) =1 + 1;
modify(iarr);
for (int i = 0; i < 5; ++i)
cout << *(iarr + i) << " ";
return 0;
}
Answer :- 

5. Consider the following program?

#include <iostream>
#include <vector>
int main() {
std: :vector<int> cVec(3, -1);
for(int i = 0; i < 3; i++)
cVecl[il = (i + 1) * 10;
cVec.resize(3);
cVec.resize(3, 110);
for(int i = 0; i < 3; i++)
cVec.push_back((i + 1) * 20);
for(int i = 0; i < cVec.size(); i++)
std::cout << cVec[i] << " ";
return 0;
}
Answer :- 

6. Consider the following program?

#include <iostream>

#include <algorithm>

using namespace std;

int main() {
int iarr[] = {10, 20, 50, 40, 10, 50};
rotate(&iarr([0], &iarr[2], &iarr[6]);
____________c//LINE-1
for(int i = 0; i < 4; ++i)

cout << iarr[i] << " ";

return 0;

}
Answer :- 

7. Consider the following program?

#include <iostream>
#include <algorithm>
using namespace std;
int mainQ) {
int idatall = {1, 2, 3, 4, 5 };
int n = sizeof(idata) / sizeof (*idata);
for (int i = 0; i < n/2; i++) {
int temp = idatalil;
replace(idata, idata + 5, temp, *(idata +n - i - 1));
replace(idata + i + 1, idata + 5, idataln - i - 1], temp);
}
for (int i = 0; i < 5; ++i)
cout << idatalil << " ";
return 0;
}
Answer :- 

8. Consider the following program?

#include <iostream>
#include <string>
using namespace std;
int main(void) {
string stri = "Modern ";
string str2 = "C++";
et B LIRS //LINE-1
cout << stri;
return 0;
}
Answer :- 

9. Consider the following program?

#include <iostream>

#include <algorithm>

using namespace std;

int main() {
int iArr[] = {40, 50, 10, 30, 20};
sort (iArr, iArr + 4);
for (int i = 0; i < 5; i++)
cout << *(iArr + i) << " ";
return 0;

}
Answer :-