An Introduction To Programming Through C++ Assignment 10 Answers

NPTEL An Introduction To Programming Through C++ Assignment 10 Answers 2022:-In This article, we have provided the answers of An Introduction To Programming Through C++ Assignment 10. You must submit your assignment to your own knowledge.

What is An Introduction to Programming Through C++?

This course provides an introduction to 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 strategies to computer programs. Organizing large programs into units such as functions and classes. Introduction to assertions and invariants.
  • Programming applications. Arithmetic on polynomials, 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.

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.

An Introduction To Programming Through C++Answers
Assignment 1Click Here
Assignment 2Click Here
Assignment 3Click Here
Assignment 4Click Here
Assignment 5Click Here
Assignment 6Click Here
Assignment 7Click Here
Assignment 8Click Here
Assignment 9Click Here
Assignment 10Click Here
Assignment 11Click Here
Assignment 12NA

NPTEL An Introduction to Programming Through C++ Assignment 10 Answers 2022:-

Q1. To create an array of integers which can be accessed as A[0],…,A[4] residing on the heap the code to be executed is:

a. int A[5]; 
b. int *A = new int[5]; 
c. int A = new int[5];
d. int new A[5];

Answer:- b. int *A = new int[5]; 

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

An Introduction To Programming Through C++ Assignment 10 Answers

Q2. My program contains the line:

delete x;

It does not cause a compile time error. Which of the following is a possibledeclaration for x?

  • int x; 
  • double x; 
  • double *x; 
  • int x[10];

Answer: c

Q3. What is a memory leak? Pick the nearest description from those below.

  • The term refers to a pointer which does not point to a valid memory location. 
  • The term refers to a location in heap memory which has been allocated but to which your program has no pointer. 
  • The term refers to a memory location which is faulty. 
  • The term refers to a pointer which points to memory that has been deallocated.

Answer: b

Q4. What is a dangling pointer? Pick the nearest description from those below.

  • The term refers to a pointer which does not point to a valid memory location. 
  • The term refers to a location in heap memory which has been allocated but to which your program has no pointer. 
  • The term refers to a memory location which is faulty. 
  • The term refers to a pointer which points to memory that has been deallocated.

Answer: d

Q5. When we created the String class we redefined the = operator because

Answer: c

👇FOR NEXT WEEK ASSIGNMENT ANSWERS👇

An Introduction To Programming Through C++ Assignment 10 Answers

Q6. When I define the destructor for a class, under what circumstances should it delete the heap memory that a data member points to?

Answer:- b

Q7. What is the first number printed?

Answer: 10

Q8. What is the second number printed?

Answer: 9

Q9. What is the third number printed?

Answer: 8

If there are any changes in answers will notify you on telegram so you can get a 100% score, So Join

Q10. Consider the following code fragment (assume appropriate header files have been loaded and using namespace commands issued)

Answer:- For Answer Click Here

Q11. What should blank2 be?

Answer: xchgRate->first

Q12. What should blank3 be?

Answer: xchgRate->second

Q13. For which currency is the exchange rate printed first by the third statement?

Answer: a

Programming Assignment Answers:-

Q1. Write a program which reads in and executes very simple programs in a very simple programming language which is as follows. The language has 4 statements, with the following formats.

Code:-

#include<iostream>
#include<map>
using namespace std;
  
int main(){
  string s;
  map<char,int>m;
  while(getline(cin,s)){
    if(s[0]=='d'){
      m[s[7]]=s[9]-'0';
    }
    else if(s[0]=='p'){
      for(auto x:m){
        if(x.first==s[6]){
          cout<<x.second<<endl;
        }
      }
    }
    else if(s[0]=='a'){
      auto it1 = m.find(s[4]);
      auto it2 = m.find(s[9]);
      it2->second += it1->second;
    }
    else if(s[0]=='e'){
      return 0;
    }
  }
  return 0;
}

Q2. You are to write a function addM to add together two matrices, which are implemented as vectors of vectors. The matrices will only contain integers. If the matrices to be added are A,B and the sum is C, then we want C[i][j]=A[i][j]+B[i][j] for all i,j.

Code:-

vector<vector<int>> addM(const vector<vector<int>>& A, const vector<vector<int>>& B) {
  vector<vector<int>> matrix(A);
  for (size_t i = 0; i < matrix.size(); i++)
      for (size_t j = 0; j < matrix[0].size(); j++)
          matrix[i][j] += B[i][j];
  return matrix;
}

NPTEL An Introduction To Programming Through C++ Assignment 10 Answers 2022:-In This article, we have provided the answers of An Introduction To Programming Through C++ Assignment 10. You must submit your assignment to your own knowledge.

Leave a Comment