An Introduction To Programming Through C++
IIT Bombay.
Week 1 Quiz 1:
Fill in the blank in the following program that draws a figure resembling the letter 'M' (lying on its side). Remember that the turtle starts at the center of the canvas and facing right.
forward(100); right(150); forward(50); left(120); forward(50); right(BLANK1); forward(100);
1.What is BLANK1?
Ans:150
------------------------------------------------------------------------------------------------------------------------
Fill in the blanks in the following program so that it will print the string "bbbaaaabbbaaaabbbaaaa"
repeat(BLANK2){
repeat(BLANK3){
cout << "b";
}
repeat(BLANK4){
cout << "aa";
}
}
2.What is BLANK2?
Ans:3
3.What is BLANK3?
Ans:3
4.What is BLANK4?
Ans:2
--------------------------------------------------------------------------------------------------------------------------
Fill in the blanks in the following program so that it draws an array of 16 tiles, organized in 4 rows of 4 tiles each, with each tile being a square of side length 100 and there being 10 pixels between consecutive tiles in each row. The tiles are placed with sides vertical and horizontal.
repeat(4){
repeat(4){
repeat(4){
forward(100);
right(90);
}
penUp();
BLANK5
penDown();
}
penUp(); forward(BLANK6); right(90); forward(BLANK7); right(270); penDown();
}
5.What is BLANK5?
Hint: A complete command is expected here. Please do not include any blanks/white space
Ans:forward(100);
6.What is BLANK6?
Hint: A negative number is expected here.
Ans:440
7.What is BLANK7?
Hint: A positive number is expected here.
Ans:110
-----------------------------------------------------------------------------------------------------------------------
Suppose we have a 5 x 5 pixel image. The pixels in the top row are numbered 0 through 4 left to right, the ones in the second row from the to are numbered 5 through 9 left to right, and so on. Suppose this image contains a '+' symbol at the center, and the bars in the '+' are 1 pixel wide and 3 pixels long, with the central pixel appearing in both the horizontal and vertical bars. The pixels corresponding to the '+' have value 1 and others have value 0.
8.What is the value of the pixel numbered 6?
Ans:0
9.How many pixels have value 1?
Ans:5
10.What are the numbers of pixels with value 1?
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Ans:7,11,12,13,17.
-------------------------------------------------------------------------------------------------------------------------
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 the number i. Thus the king of spades will get the number 52, and the ace of clubs the number 1.
11.What number does the 9 of spades get?
Ans:48
-------------------------------------------------------------------------------------------------------------------
12.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?
i->n > 26
ii->ceiling(n/13) = 2
iii->n mod 13 = 0
iv->floor(n/13) = 2
-------------------------------------------------------------------------------------------------------------------------
13.When you multiply an n digit number by an m digit number manually, then number of digit wise multiplications you perform is:
i->m*n
ii->m+n
iii->m/n
iv->m-n
--------------------------------------------------------------------------------------------------------------------------
14.Give a machine language program which computes the cube of the number stored in address 100 and stores in address 200.
Hint: 1) Modify the fourth power program from the lecture slightly.
2) Write the answer as space separated numbers (exactly one space) with no leading or trailing space.
Ans:57 100 100 100 100 57 100 100 100 20.
WEEK :1 PROGRAMMING ASSIGNMENT 1 SOLUTION
CLICK ON BELOW LINK.
FOLLOW OUR WEBSITE FROM THE BUTTON PROVIDED TO THE BOTTOM OF PAGE TO GET SOON ANSWERS OF PROGRAMS.
Disclaimer: Here you can find all nptel assignment solutions related to CS stream.These may help you for your assignment.The answers are only for verification.You cannot copy these directly from the post(code of conduct of NPTEL).These is not 100% correct solutions.
thankyou for these please also provide me Program of assessment 1
ReplyDeleteThank you
ReplyDelete