## An Introduction to Programming Through C++ NPTEL (WEEK 1)

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

Answer: left(90)

**Q2.What is blankB?**

Answer: forward(10)

**Q3.What is blankC?**

Answer: right(90)

**Q4.What is blankD?**

Answer: forward(10)

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 hearts 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 the number 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?**

Answer: 48

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

Answer: b) ceiling(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

Answer: a) Yes

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

a) Yes

b) No

Answer: a) No

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

a) Yes

b) No

Answer: a)Yes

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

a) Yes

b) No

Answer: a)Yes

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

Answer: 294

Your are given two tables

Table 1: (A) Control unit, (B) memory (C) compiler (D) capacitor

Table 2: (E) Can be used to store a bit, (F) Can be used to store many bits, (G) translates C++ program into machine language, (H) Fetches instructions

**Q12.What most closely matches A?**

a) E

b) F

c) G

d) H

Answer: d) H

**Q13.What most closely matches B?**

a) E

b) F

c) G

d) H

Answer: b) F

**Q14.What most closely matches C?**

a) E

b) F

c) G

d) H

Answer: c) G

**Disclaimer:** These answers are provided only for the purpose to help students to take references. This website does not claim any surety of 100% correct answers. So, this website urges you to complete your assignment yourself.

**ALSO READ:**

## Leave a comment