NPTEL An Introduction to Programming Through C++ Assignment 5 Answers 2022

NPTEL An Introduction to Programming Through C++ Assignment 5

Are you looking for the Answers to NPTEL An Introduction to Programming Through C++ Assignment 5? This article will help you with the answer to the National Programme on Technology Enhanced Learning (NPTEL) Course “ NPTEL An Introduction to Programming Through C++ Assignment 5

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.

Below you can find the answers for NPTEL An Introduction to Programming Through C++ Assignment 5

Assignment No.Answers
An Intro to Programming C++ Assignment 1 Click Here
An Intro to Programming C++ Assignment 2 Click Here
An Intro to Programming C++ Assignment 3 Click Here
An Intro to Programming C++ Assignment 4 Click Here
An Intro to Programming C++ Assignment 5 Click Here
An Intro to Programming C++ Assignment 6 Click Here
An Intro to Programming C++ Assignment 7 Click Here
An Intro to Programming C++ Assignment 8 Click Here

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

Q1. Consider the following program.

#include<simplecpp>
int func(int a) {
	a = 1;
	return 0;
}
main_program {
	int a = 10;
	func(a);
	cout << a << endl;
}

Answer:- A

Q2. Consider the following program

#include<simplecpp>
int func(int &a){
a += 10;
return a * 10;
}
main_program {
int b = 1, a = 1;
a = func(b);
cout << b << endl;
}

Answer:- a

Q3. The above program is invalid. What will happen when the program is compiled? Select the line number where the compiler will throw an error.

Answer:- c

???? Next Week Answers: Assignment 06 ????

quizxp telegram

Q4. What is the maximum number of activation frames that might be present for the call f(2,12), where f is defined as follows? (Include the activation from the main_program in both cases in the count).

Answer:- d

Q5. use the definition of f given in the above question

Answer:- b

Q6. What value is returned by mystery(a,b) where the mystery function is as defined above?

Answer:- c

Q7. What does the following function do if arguments passed are (&a,&b) where a and b are integers?

Answer:- c

Given below is an implementation of multiplication of two numbers via addition. It is based on the idea that a*n = a+a…n times.int mult_add(int a, int n){

Q8. What is BLANK-A?

Answer:- 0

Q9. What is BLANK-B?

Answer:- a

Q10. What is BLANK-C?

Answer:- n-1

Programming Assignment

Q1. Write a function that takes a number b, and a number N, and returns true/false indicating whether N is a power of b, ie bk=N for some non negative integer k. The function returns true if N can be expressed as a power of b, and false otherwise.Use the following function signature :bool isPower(int b,int N).The following code will be there, but won’t appear in your editor :main_program{int b,N;cin>>b>>N;if(isPower(b,N))cout<<“Yes”<<endl;elsecout<<“No”<<endl;}This invisible code will test your function. This code will read the values b and N from the test case and print out “Yes” if your function returns true and “No” otherwise.

Code:-

bool isPower(int b,int N)
{
  int p=b;
  while(p<N)
  {
    p=p*b;
  }
  if(p==N)
    return 1;
  else
    return 0;
}

Q2. Write a void function that takes two value parameters : a and b, and two reference parameters :q and r. It performs the integer division of a by b, and stores the quotient in q and the remainder in r. All the values : a, b, q and r can be stored in the int data type.Use the following function signature :void div(int a, int b, int &q, int &r).

Code:-

void div(int a,int b,int &q,int &r)
{
  *(&q)=a/b;
  *(&r)=a%b;
}

For other courses answers:- Visit

For Internship and job updates:- Visit

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.