# An Introduction To Programming Through C++ Assignment 5 Answers

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

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

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;
}``````

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;
}``````

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.

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).

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

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

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

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?

Q9. What is BLANK-B?

Q10. What is BLANK-C?

## 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:-

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:-

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.