CS2 HW1 Fall2022-1
CS2 HW1 Fall2022-1
1. What is the data type of the variable y in the following assignment statement: y = “Welcome”
a. String b. Boolean c. Text d. Integer
a. 9 b. 22 c. 7 d. 12
a. True b. False c. 1 d. 4
6. What is the output for the following pseudo code, given the following numbers (7,12,14)?
1. C = 2
2. Increment C by 2
3. If C <= 6 then Go to step 5
4. Go to step 8
5. Input x
6. Print “x” , x+1
7. Go to step 2
8. End
a. 7 12 12 14 14 b. 8 8 13 13 14 14 c. x 7 x 12 x 14 d. x 8 x 13 x 15
1
7. The following Flowchart symbol presents:
a) b) c) d)
1.Start 1. Start 1. Start 1. Start
2.x=8 , y=10 2. x=8 , y=10 2. X=8, y=10 2. x=8 , y=10
3. If x>y+3 then print 3. If x>y+3 then print 3. If x>y+3 then print 3. If x>y+3 then print
“Large” else print “Small” else print “Large” “Large” else print
“Small” “Large” 4. print “Small”, Print “Small”
4. Print “Good” 4. Print “Good” “Good” 4. Print y
5. If y<> 13 then print y 5. If y<> 13 then 5. If y <> 13 then print y 5. If y<> 13 then
6.Stop print y 6. Stop print “Good”
6. Stop 6. Stop
10. Which of the following assignment statements is not correct?
a. x=z-5 b. x*2 = y c. z=z^2 d. y=z
2
11. What is the output for the following flowchart?
12. What is the equivalent Pseudo Code for the flowchart in question 11?
a.1. Start b.1. Start c. 1. Start d.1. Start
2. Let x = 1, y = 2 2. Let x = 1, y = 2 2. Let x = 1, y = 2 2. Let x = 1, y = 2
3. Let z = 4 3. Let z = 4 3. Let z = 4 3. Let z = 4
4. y = y + x + z 4. y = y + x + z 4. y = y + x + z 4. y = y + x + z
5. print y 5. print y 5. print y 5. print y
6. If y < 15 then 6. If y < 15 then 6. If y < 15 then 6. If y < 15 then
Print “Finish” Goto 4 y=y+x+z Goto 3
Stop 7. Print “Finish” print y 7. Print “Finish”
7. y = y+x+z 8. Stop 7. Print “Finish” 8. Stop
8. print y 8. Stop
13. Which of the following pseudo code will read a number and then print whether it’s odd فرديor
even زوجيnumber?
a. 1. Input x b.1. Input x c. 1. Input x d. None of them
2. if x mod 2= 0 2. if x mod 2= 0 then 2. if x mod 2 = 0 then
then Print “x is Print “x is odd” Print “x is even” else
even” 3. Print “x is even” Print “x is odd”
3. Print “x is odd”
3
14. What is the output for the following flowchart?Assume
that the inputs are: 15 , 16 , 17 , 18 , 22