An Introduction To Programming Through C++ Assignment 8 Answers

NPTEL An Introduction To Programming Through C++ Assignment 8 Answers 2022:-In This article, we have provided the answers of An Introduction To Programming Through C++ Assignment 8. 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 11NA
Assignment 12NA

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

Q1. What will get printed due to the line labeled A above?

a. The letter ‘a’ 
b. The letter ‘b’ 
c. The letter ‘c’ 
d. It is not possible to predict what will be printed.

Answer:- c. The letter ‘c’ 

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

An Introduction To Programming Through C++ Assignment 8 Answers

Q2. What will get printed due to the line labeled B above?

  • The letter ‘a’ 
  • The letter ‘b’ 
  • The letter ‘c’ 
  • It is not possible to predict what will be printed.

Answer: d. It is not possible to predict what will be printed.

Q3. In the same code, suppose the user typed “abcdefghijkl”. Which of the following are true?

  • C++ will change the array size so that what the user types will be accommodated. 
  • What the user types will potentially be stored in regions of memory not allocated for the variable buffer. 
  • There is a different way in C++ to read data into char arrays so that no other variables get affected.

Answer: b. What the user types will potentially be stored in regions of memory not allocated for the variable buffer. 

Q4. What will the value of argc be?

Answer: 4

Q5. What will the value of argv[2][2] be? Write without placing quotes etc.

Answer: u

👇FOR NEXT WEEK ASSIGNMENT ANSWERS👇

An Introduction To Programming Through C++ Assignment 8 Answers

Q6. Suppose the binary search function BSearch is called using an array of size 128. How many calls will there be including the initial?

Answer:- 8

Q7. What will be the size of the array U declared in it?

Answer:- For Answer Click Here

Q8. After mergesort has been called on U, V, what will V[0] equal?

Answer: 1

Q9. Select the correct statements among those given below. Assume that the sequence considered for sorting contains distinct elements.

Answer: a

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

Q10. Consider the merge function called to merge two sorted sequences of lengths m, n respectively. Suppose m < n. What is the minimum number of comparisons (between the elements of the sorted sequence)that the merge function must perform, no matter what the values of the elements?

Answer: a

Q11. What is L?

Answer: 16

Q12. What will the first line print?

Answer:- For Answer Click Here

Q13. What will the last line print?

Answer: f

Programming Assignment Answers:-

Q1. Write a program which takes the following as input: an integer N, an integer A, a sequence of N words which should be names of countries, a sequence of A words each of which is an attribute of a country (e.g. population, area, GDP), followed by a sequence of N*A real numbers (use double) where the iA+j th number gives the value of the jth attribute of the ith country, where 0<=j<A, 0<=i<N, followed by a sequence of pairs of words. The first word in each pair must be the name of a country, and the second an attribute. The program must then print the respective attribute of the respective country (e.g. population of India, GDP of China).

Code:-

#include<iostream>

using namespace std;
int main()
{
  int N,A;
  cin>>N>>A;
  string Country[N];for(int i=0;i<N;i++) cin>>Country[i];
  string Attribute[A];for(int i=0;i<A;i++) cin>>Attribute[i];
  float valArray[N*A];for(int i=0;i<N*A;i++) cin>>valArray[i];
  
  float ans[20]; int count=0;
  
  while (!cin.eof())
  {
    string _cntry,_attr;
    cin>> _cntry;
    cin>> _attr;
   
    int _cIndex=0;
    while (_cIndex<N)
    {
      if(Country[_cIndex]==_cntry)
      {break;}
      _cIndex++;
    }
    
    int _aIndex=0;
    while (_aIndex<N)
    {
      if(Attribute[_aIndex]==_attr)
                   {break;}
                   _aIndex++;
                   }
                   float _ans=valArray[(3*_cIndex)+_aIndex];
                   ans[count]=_ans;
                   count++;
                   }
                   for(int i=0;i<count-1;i++)
                   {
                     cout<<ans[i]<<endl;
                   }
                   return 0;
                   }

Q2. You are to write a function makeT that takes as input a set S of integers, and a target value T, and determines if any subset of the numbers in Sadds up to T. The function should be a modification of the function given in the quiz for printing all subsets of a set. The function should have thefollowing signature:

Code:-

bool makeT(int S[], bool selected[], int i, int n, int T)
{

    bool set[n + 1][T + 1];

    for (int i = 0; i <= n; i++)
        set[i][0] = true;

    for (int i = 1; i <= T; i++)
        set[0][i] = false;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= T; j++)
        {
            if (j < S[i - 1])
                set[i][j] = set[i - 1][j];
            if (j >= S[i - 1])
                set[i][j] = set[i - 1][j] || set[i - 1][j - S[i - 1]];
        }
    }

    return set[n][T];
}

👇FOR NEXT WEEK ASSIGNMENT ANSWERS👇

An Introduction To Programming Through C++ Assignment 8 Answers

Disclaimer:- We do not claim 100% surety of solutions, these solutions are based on our sole expertise, and by using posting these answers we are simply looking to help students as a reference, so we urge do your assignment on your own.

For More NPTEL Answers:- CLICK HERE

Join Our Telegram:- CLICK HERE

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

4 thoughts on “An Introduction To Programming Through C++ Assignment 8 Answers”

Leave a Comment