NPTEL An Introduction To Programming Through C++ Assignment 5 Answers 2022 :- Here All The Questions and Answers Provided to Help All The Students and NPTEL Candidate as a Reference Purpose, It is Mandetory to Submit Your Weekly Assignment By Your Own Understand Level.
Are you looking for the Assignment Answers to NPTEL An Introduction To Programming Through C++ Assignment 5 Answers 2022? If Yes You are in Our Great Place to Getting Your Solution, This Post Should be help you with the Assignment answer to the National Programme on Technology Enhanced Learning (NPTEL) Course “NPTEL An Introduction To Programming Through C++ Week 5 Solution 2022”
An Introduction To Programming Through C++
From My Side : This course provides an start to problem solving and programming using the C++ programming language. The topics tallying together occurring:
Basic programming notions. Control flow, variables and assignments statements, conditional be swift, looping, action calls including recursion. Arrays and structures. Elementary aspects of classes. Heap memory.
Program design. How human beings solve problems manually. Strategies for translating calendar strategies to computer programs. Organizing large programs into units such as functions and classes. Introduction to assertions and invariants.
Programming applications. Arithmetic going a propos for polynomials, matrices. Root finding. Sorting and searching. Design of editors and simulators, including graphical editors. Elementary buoyancy. A rudimentary graphics system will be discussed.
Standard Library of C++. The string, vector and map classes.
C++ is an slant-oriented programming language which gives a sure structure to programs and allows code to be reused, lowering fee costs
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
This course can have Associate in Nursing unproctored programming communication conjointly excluding the Proctored communication, please check announcement section for date and time. The programming communication can have a weightage of twenty fifth towards the ultimate score.
- Assignment score = 25% of average of best 8 assignments out of the total 12 assignments given in the course.
- ( All assignments in a particular week will be counted towards final scoring – quizzes and programming assignments).Â
- Unproctored programming exam score = 25% of the average scores obtained as part of Unproctored programming exam – out of 100
- Proctored Exam score =50% of the proctored certification exam score out of 100
UNPROCTORED PROGRAMMING EXAM SCORE >=10/25 AND PROCTORED EXAM SCORE >= 20/50.Â
CHECK HERE OTHERS NPTEL ASSIGNMENTS ANSWERSÂ
BELOW YOU CAN GET YOUR NPTEL An Introduction To Programming Through C++ Assignment 5 Answers 2022? :
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;
}
What is the output of the program?
a) 1
b) 10
c) 0
d) Can’t be determined
Answer By SciShowEngineer
Answer: a) 1
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;
}
What is the output of the program?
a) 11
b) 110
c) 1
d) Can’t be determined
Answer By SciShowEngineer
Answer: a) 11
Q3. Consider the following program.
#include<simplecpp>
int func(int *a){ //1
return a * 10; //2
} //3
//4
main_program{ //5
int a = 1; //6
int b = *(&a); //7
cout << func(&a); //8
} //9
The above program is invalid. What will happen when the program is compiled? Select the line number where the compiler will throw an error.
a) It will compile correctly and the output will be 1
b) It will compile correctly and the output will be 10
c) It will throw an error at line 2
d) It will throw an error at line 7
Answer By SciShowEngineer
Answer: c) It will throw an error at line 2
Q4. Consider the following program.
int f(int a, int b)
{
if(a>b) return a-b;
else return f(a+1,b/2);
}
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).
a) 1
b) 2
c) 3
d) 4
Answer By SciShowEngineer
Answer: d) 4
Q5.
a) 1
b) 2
c) 3
d) 4
Answer By SciShowEngineer
Answer: b) 2
Q6. Consider the following program.
#include <iostream>
using namespace std;
int mystery(int a, int b)
{
if (b == 0)
return 0;
if (b % 2 == 0)
return mystery(a + a, b/2);
return mystery(a + a, b/2) + a;
}
What value is returned by mystery(a,b) where the mystery function is as defined above?
a) 2*(a+b)+1
b) a*b+a
c) a*b
d) None of the above
Answer By SciShowEngineer
Answer: c) a*b
Q7. What does the following function do if arguments passed are (&a,&b) where a and b are integers?
void func1(int *ptr_a, int *ptr_b){
int * tem;
tem=ptr_b;
ptr_b=ptr_a;
ptr_a=tem;
}
a) Swaps value of a and b
b) Swaps pointers to a and b
c) Doesn’t change anything
Answer By SciShowEngineer
Answer: c) Doesn’t change anything
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){
if(n==BLANK-A) return 0
else{
int recurse = mult_add(BLANK-B, BLANK-C);
int ans = a+ recurse;
return ans;
}
}
Q8. What is BLANK-A?
Answer By SciShowEngineer
Answer: 0
Q9. What is BLANK_B?
Answer By SciShowEngineer
Answer: a
Q10. What is BLANK_C?
Answer By SciShowEngineer
Answer: n-1
NPTEL An Introduction To Programming Through C++ Programming Assignment 5 Answers 2022
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;
else
cout<<“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.
You don’t need to write/copy the main program. You just need to write the isPower function, without the main_program or any of the header files.
Note : Ensure that the name of the function is isPower and it takes the two parameters and returns true or false without printing anything.
Explanation of Sample Testcase 1
Input : b=2, N=1024
Output : 1024 can be expressed as 210. So the function returns true and Yes gets printed out by the invisible code.
CODE:
bool isPower(int b, int N) {
int p = b;
while(p < N)
p *= b;
if(p == N)
return 1;
else
return 0;
}
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).
The following code will be there, but won’t appear in your editor :
main_program{
int a,b,q,r;
cin>>a>>b;
div(a,b,q,r);
cout<<q<<” “<<r<<endl;
}
This invisible code will test your function. This code will read the values a and b from the test case, call your div function and will print out the modified values of q and r.
You don’t need to write/copy the main program. You just need to write the div function, without the main_program or any of the header files.
Note : Ensure that the name of the function is div, and it takes the four parameters and stores the quotient and remainder of the division a/b in q and r without printing anything.
Explanation of Sample Testcase 1
Input : a=30, b=7
Output : 30/7 gives 4 as the quotient and 2 as the remainder. After the function returns, q contains 4 and r contains 2
CODE:
void div(int a, int b, int &q, int &r) {
*(&q) = a/b;
*(&r) = a%b;
}
Yhaa You have done it but next? if YOU Want to your Others NPTEL An Introduction To Programming Through C++ Assignments Answers Then Follow US HERE and Join Telegram.
Everything is very open with a really clear description of the issues. It was definitely informative. Your site is very helpful. Many thanks for sharing!