**NPTEL An Introduction To Programming Through C++ Assignment 3 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 3 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 **Nation**** al Programme on Technology Enhanced LearningÂ (NPTEL)** Course “

**NPTEL An Introduction To Programming Through C++Â Week 3Â**

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

**INTENDED AUDIENCEÂ : BE/BTechÂ in all disciplines BCA/MCA/M. Sc**

**INDUSTRY SUPPORTÂ Â : All IT Industries**

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

**YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF ASSIGNMENT SCORE >=10/25 AND**

**UNPROCTORED PROGRAMMING EXAM SCORE >=10/25 AND PROCTORED EXAM SCORE >= 20/50.Â**

**If any one of the 3 criteria is not met, you will not be eligible for the certificate even if the Final score >= 40/100.Â**

**CHECK HERE OTHERS NPTEL ASSIGNMENTS ANSWERSÂ **

*BELOW YOU CAN GET YOUR NPTEL An Introduction To Programming Through C++ Assignment 3 Answers 2022***?** :

**?**:

## NPTEL An Introduction To Programming Through C++ Assignment 3 Answers 2022

int count=0;

for(int i=1; i<=5; i++){

for(int j=1; j<=5; j+=i){

for(int k=1; k<=5; k+=j){

count++;

}

}

}

Q1. What is the value of variable count at the end of execution?

Answer By SciShowEngineer

Answer: 39

A certain government levies taxes on a personâs total annual income. The taxes are calculated in the given manner.

If a person earns an amount of less than or equal to Rs. 1,00,000 annually, the person doesnât pay any tax.

If a person earns an amount of more than Rs. 1,00,000 and less than or equal to Rs. 5,00,000, then the person is charged 5% on the amount.

If a person earns an amount of more than Rs. 5,00,000, the person is charged with 5% of Rs. 5,00,000 and 10% of the remaining amount.

The following code snippet computes the total tax to be paid by a person given their annual income. You are to fill in the blanks so that the code computes the tax correctly.

int income;

cin>>income;

double tax;

if(income<=blank1){

tax=0;

}

else if(income<blank2){

tax=blank3*income

}

else{

tax=0.05*500000+0.10*(blank4)

}

cout<<tax<<endl;

Q2. What should be filled in blank1?

a) 0

b) 100000

c) 500000

d) 1000000

Answer By SciShowEngineer

Answer: b) 100000

Q3. What should be filled in blank2?

a) 0

b) 100000

c) 500000

d) 1000000

Answer By SciShowEngineer

Answer: c) 500000

Q4. What should be filled in blank3?

a) 0

b) 0.05

c) 0.1

d) 0.5

Answer By SciShowEngineer

Answer: b) 0.05

Q5. What should be filled in blank4?

a) income

b) income-100000

c) income-500000

d) Income+100000

Answer By SciShowEngineer

Answer: c) income-500000

Given below is a program fragment that is meant to calculate the average of all odd numbers given in the input. You are to fill in the blanks so that the code computes the average correctly.

int sum=0;

int count=0;

for(int i=0; i<n; i++){

int num;

cin>>num;

if(num%2==0){

blank5;

}

blank6;

blank7;

}

cout<<sum/count<<endl;

Q6. What should be filled in blank5?

a) break

b) continue

c) sum+=num

d) return 0

Answer By SciShowEngineer

Answer: b) continue

Q7. What should be filled in blank6?

a) continue

b) break

c) sum+=num

d) sum*=num

Answer By SciShowEngineer

Answer: c) sum+=num

Q8. What should be filled in blank7?

a) count+=1

b) count-=1

c) count+=num

d) count+=2

Answer By SciShowEngineer

Answer: a) count+=1

The program given below is meant to read an unending sequence of non-negative numbers. This sequence may increase and decrease several times. We are interested in the last increasing portion, particularly its length. So having read a number, the program prints out the length of the last increasing portion. Suppose the sequence is 1, 4, 6, 2, 5, âŠ Then having read 1, 4, 6 the program will print 3, because at this point the entire sequence forms the increasing portion. On the other hand, having read 1, 4, 6, 2, 5 the program should print 2 because the last increasing portion is 2, 5, of length 2. You can see that the program will have to print out 1, 2, 3, 1, 2 and so on if the input was 1, 4, 6, 2, 5, âŠ. You are to answer the questions below in order to fill in the blanks so that the program does its job.

int lastSeqLength=0; // stores the current length of sequence which is continuously increasing

int last=-1;

while(true){

int num;

cin>>num;

if(num>last){

blank8;

}

else{

blank9;

}

last=num;

cout<<lastSeqLength<<endl;

}

Q9. What should be filled in blank8?

a) lastSeqLength=0

b) lastSeqLength=1

c) lastSeqLength+=1

d) lastSeqLength-=1

Answer By SciShowEngineer

Answer: c) lastSeqLength+=1

Q10. What should be filled in blank9?

a) lastSeqLength=1

b) lastSeqLength=0

c)lastSeqLength+=1

d) lastSeqLength-=1

Answer By SciShowEngineer

Answer: a) lastSeqLength=1

## NPTEL An Introduction To Programming Through C++ Programming Assignment 3 Answers 2022

You are currently at the origin (0, 0) and will be given commands to either go Right (R), Left (L), Up (U) or Down (D) by a certain number of steps. At the end of all these commands, you will be signaled to stop by reading the character âEâ, after which you need to output your position in the x-y plane. The four kinds of movements are the following (direction followed by number of steps in that direction):

R number_of_steps : You need to increase your x-coordinate by ânumber_of_stepsâ.

L number_of_steps : You need to decrease your x-coordinate by ânumber_of_stepsâ.

U number_of_steps : You need to increase your y-coordinate by ânumber_of_stepsâ.

D number_of_steps : You need to decrease your y-coordinate by ânumber_of_stepsâ.

INPUT:

Direction number_of_steps (a character and integer separated by a space)

.

.

.

E (command to stop)

OUTPUT:

x y

CODE:

int main() {

int x = 0, y = 0, steps;

char ch;

cin >> ch >> steps;

while(ch != ‘E’) {

switch(ch) {

case ‘R’: x = x + steps;

break;

case ‘L’: x = x – steps;

break;

case ‘U’: y = y + steps;

break;

case ‘D’: y = y – steps;

break;

default: break;

}

cin >> ch >> steps;

}

cout << x << ” ” << y << endl;

}

Programming Assignment 3.2

Write a program to find the sum of the digits of a given integer N.

Solving this problem is easy manually if the number is given to you on paper: you simply see the digits written down and you can add them up. A computer program does not âseeâ the digits. However, you can get the least significant digit by taking the remainder modulo 10, using the % operator. You can determine the number resulting from erasing the least significant digit of an integer x by dividing x by 10. As you know x/10 will equal the quotient, which is exactly what remains if you erase the last digit of x. If you now take the remainder of this modulo 10 you will get the second least significant digit. Thus by alternately taking the remainder modulo 10 and dividing by 10 you will be able to obtain the different digits. So then you can add them up. All that remains is to put this into a nice loop.

INPUT:

N (1<=N<=1000000000). The upper bound for N is set at 109 so that the numbers will fit in standard int.

OUTPUT:

Sum of digits of N

CODE:

int main() {

int n, sum = 0;

cin >> n;

while(n > 0) {

sum = sum + n % 10;

n = n / 10;

}

cout << sum << endl;

}

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.