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

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

Suppose a “rightgoing step” consists of a upward going line of length 10 followed by a rightgoing line of length 10.  The following code draws 5 rightgoing steps, i.e. a staircase.  Assuming the turtlestarts pointing in the rightward direction, and assuming the steps rise by 50 in the right fill in the blanks.
repeat(5){ blankA; blankB; blankC; blankD;}
Given below are 4 fill in the blank questions.  You have to answer by writing only the required answer without any blanks or anything, as it would appear in your program.  For example for the first question you should fill “left(90)” (without the quotes).

Q1. What is blankA?

Q2.What is blankB?

Q3. What is blankC?

Q4. What is blankD?

Suppose you decide to represent the cards in a standard deck using the numbers 1 through 52. So for this, the cards are arranged so that the clubs come first, then the diamonds, then the heards and then the spades. Also within a suit, the order of the cards is ace, then the cards 2 through 10, then the jack, then the queen, then the king. So after arranging the cards in this manner, the ith card is assigned thenumber i. Thus the king of spades will get the number 52, and the ace of clubs the number 1.

Q5. What number does the 9 of spades get?

Q6. Suppose some card has number n. I would like to know if it is a diamond. Which of the following tests will tell me if this is the case?

a. n > 26
b. ceiling(n/13) = 2
c. n mod 13 = 0
d. floor(n/13) = 2

Suppose I choose to represent a number using floating point, in 32 bits, using the representation discussed in the lecture.  Which of the following are correct?

Q7. I will be able to exactly represent the number 100000000 (100 million).

a. Yes
b. No

Q8. I will be able to approximately represent the number 1000000000000 (one trillion)

a. Yes
b. No

Q9. I will be able to exactly represent the number 1000.

a. Yes
b. No

Q10. I will be able to exactly represent the number 1/3 (one third).

a. Yes
b. No

Q11. Consider the multiplication instruction defined in the lecture.
Suppose now that I have a program 57 100 200 300 57 300 200 400.Suppose initially the 6, 7, 8, 9 are stored in addresses 100, 200, 300, 400 respectively.  After executing the 2 instructions given above, what would be present at address 400?

Q12. What most closely matches A?

a. E
b. F
c. G
d. H

Q13. What most closely matches B?

a. E
b. F
c. G
d. H

Q14. What most closely matches C?

a. E
b. F
c. G
d. H

Programming Assignment 1.1

Q1. Write a program that reads in numbers m, n and prints the letter X (capital X) m times followed by the letter Y (capital Y) n times, all in one line. Don’t write the #include < simplecpp > statement at the beginning of your code, directly start the main_program

Code:-

`````` int main() {
int m,n;
cin>>m>>n;
while(m--)
cout<<"X";
while(n--)
cout<<"Y";
return 0;
}``````

Q2. Write a program that reads in a number m and prints a ‘*’ on m consecutive lines, followed by m+1 ‘*’s on a single line.  The result should look like the letter L made out of stars. You can go to a new line in the output using cout << endl; .Don’t write the #include < simplecpp > statement at the beginning of your code, directly start the main_program

Code:-