0% found this document useful (0 votes)
7 views13 pages

Assignment 1 1

The document contains a series of pseudocode questions and answers related to programming concepts, including loops, conditionals, and calculations. Each question requires tracing through the pseudocode or analyzing its output to select the correct answer from multiple-choice options. The questions cover various programming topics and logic, aimed at assessing understanding of pseudocode structures.

Uploaded by

Harsh Sri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views13 pages

Assignment 1 1

The document contains a series of pseudocode questions and answers related to programming concepts, including loops, conditionals, and calculations. Each question requires tracing through the pseudocode or analyzing its output to select the correct answer from multiple-choice options. The questions cover various programming topics and logic, aimed at assessing understanding of pseudocode structures.

Uploaded by

Harsh Sri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Pseudocode Assignment-1

05-06-2025
Q1. Trace through this nested loop:

BEGIN
result = 0
FOR i = 1 TO 4
FOR j = 1 TO i
result = result + j
END FOR i
PRINT result
END

A) 10 B) 15 C) 20 D) 25

Q2. What does this pseudocode calculate?

BEGIN
n = 729
count = 0
WHILE n > 1
n = n / 3
count = count + 1
END WHILE
PRINT count
END

A) 6 B) 5 C) 4 D) 7

Q3. Analyze this pattern generation:

BEGIN
n = 4
FOR i = 1 TO n
FOR j = 1 TO (n - i + 1)
PRINT j
END FOR j
PRINT NEWLINE
END FOR i
END

A) 8 B) 10 C) 12 D) 16
Q4. What will this pseudocode output?

BEGIN
a = 7, b = 3
FOR k = 1 TO 5
temp = a % b
a = b
b = temp
IF b == 0
BREAK
END IF
END FOR
PRINT a
END

A) 0 B) 1 C) 3 D) 7

Q5. Trace this complex loop:

BEGIN
result = 1
FOR i = 2 TO 6
FOR j = 1 TO i
IF j % 2 == 1
result = result * j
END IF
END FOR j
END FOR i
PRINT result
END

A) 225 B) 675 C) 1125 D) 2025


Q6. What does this pseudocode compute?

BEGIN
n = 64
result = 0
WHILE n > 0
IF n % 2 == 1
result = result + 1
END IF
n = n / 2
END WHILE
PRINT result
END

A) 1 B) 2 C) 6 D) 64

Q7. What will be printed?

BEGIN
base = 2, exp = 8
result = 1
WHILE exp > 0
IF exp % 2 == 1
result = result * base
END IF
base = base * base
exp = exp / 2
END WHILE
PRINT result
END

A) 16 B) 64 C) 128 D) 256
Q8. What does this pseudocode calculate?

BEGIN
num = 28
sum = 0
FOR i = 1 TO num-1
IF num % i == 0
sum = sum + i
END IF
END FOR
IF sum == num
PRINT "PERFECT"
ELSE
PRINT "NOT PERFECT"
END IF
END

A) PERFECT B) NOT PERFECT C) 28 D) ERROR

Q9. Analyze this complex calculation:

BEGIN
x = 3, y = 4, z = 5
result = 0
FOR i = 1 TO 3
FOR j = 1 TO i
result = result + (x * i + y * j + z)
END FOR j
END FOR i
PRINT result
END

A) 87 B) 96 C) 112 D) 114
Q10. Determine the sequence generated:

BEGIN
a = 0, b = 1
PRINT a, b
FOR i = 1 TO 5
c = a + b
PRINT c
a = b
b = c
END FOR
END

What is the 5th number printed after the initial two?

A) 5 B) 8 C) 13 D) 21

Q11. Analyze this number pattern:

BEGIN
FOR i = 1 TO 4
FOR j = 1 TO 4
IF i == j OR i + j == 5
PRINT "1"
ELSE
PRINT "0"
END IF
END FOR j
PRINT NEWLINE
END FOR i
END

What appears in position (2,3)?

A) 0 B) 1 C) 2 D) 3
Q12. Determine the pattern:

BEGIN
FOR i = 1 TO 4
spaces = 4 - i
FOR j = 1 TO spaces
PRINT " "
END FOR j
FOR k = 1 TO (2 * i - 1)
PRINT "*"
END FOR k
PRINT NEWLINE
END FOR i
END

How many stars in the last row?

A) 5 B) 6 C) 7 D) 8

13. What does this evaluate to?

BEGIN
age = 17
hasLicense = TRUE
IF age >= 18 OR hasLicense
IF age >= 16
PRINT "Can Drive"
ELSE
PRINT "Too Young"
END IF
ELSE
PRINT "Cannot Drive"
END IF
END

A) Can Drive B) Too Young C) Cannot Drive D) ERROR


14. What does this evaluate to?

Let arr = [3, 1, 4, 1, 5, 9, 2]


sum = 0
For i = 0 to length(arr) - 1
If arr[i] > arr[(i+1) mod length(arr)]
sum = sum + arr[i]
Print sum

A) 14 B) 15 C) 16 D) 24

Q15. Determine the output:

BEGIN
a = 3, b = 7
a = a XOR b
b = a XOR b
a = a XOR b
PRINT a, b
END

A) 3, 7 B) 7, 3 C) 4, 4 D) 0, 10

Q16. Analyze this accumulator:

BEGIN
total = 0
multiplier = 1
FOR i = 1 TO 4
total = total + (i * multiplier)
multiplier = multiplier * 2
END FOR
PRINT total
END

A) 15 B) 20 C) 49 D) 30
Q17. Determine the output:

BEGIN
value = 100
WHILE value > 1
IF value % 2 == 0
value = value / 2
ELSE
value = value * 3 + 1
END IF
END WHILE
PRINT value
END

A) 0 B) 1 C) 2 D) 4

Q18. What does this nested structure produce?

BEGIN
result = 0
FOR outer = 1 TO 3
FOR inner = outer TO 3
result = result + (outer * inner)
END FOR inner
END FOR outer
PRINT result
END

A) 25 B) 30 C) 35 D) 40
Q19. Analyze this complex loop:

BEGIN
sum = 0
i = 1
WHILE i <= 10
j = i
WHILE j <= 10
sum = sum + 1
j = j + 2
END WHILE
i = i + 1
END WHILE
PRINT sum
END

A) 35 B) 30 C) 40 D) 45

Q20. Determine the result:

BEGIN
total = 0
FOR i = 1 TO 4
subtotal = 0
FOR j = 1 TO i
subtotal = subtotal + j
END FOR j
total = total + subtotal
END FOR i
PRINT total
END

A) 20 B) 25 C) 30 D) 35
Q21. Analyze this pattern:

BEGIN
value = 0
FOR i = 1 TO 3
FOR j = 1 TO 3
IF i == j
value = value + (i + j)
ELSE
value = value + 1
END IF
END FOR j
END FOR i
PRINT value
END

A) 15 B) 18 C) 21 D) 24

Q22. Determine the final value:

BEGIN
result = 0
FOR level1 = 1 TO 3
FOR level2 = level1 TO 4
result = result + (level1 * level2)
END FOR level2
END FOR level1
PRINT result
END

A) 50 B) 55 C) 49 D) 65
23. What will this string operation produce?

BEGIN
text = "HELLO"
result = ""
FOR i = 1 TO LENGTH(text)
char = SUBSTRING(text, i, 1)
result = char + result
END FOR
PRINT result
END

A) HELLO B) OLLEH C) HLLEO D) EOLLH

Q24. Analyze this character counting:

BEGIN
word = "PROGRAMMING"
vowel_count = 0
FOR i = 1 TO LENGTH(word)
char = SUBSTRING(word, i, 1)
IF char IN ["A", "E", "I", "O", "U"]
vowel_count = vowel_count + 1
END IF
END FOR
PRINT vowel_count
END

A) 2 B) 3 C) 4 D) 5
Q25. Determine the output:

BEGIN
a = 4
b = 0
c = 2
IF (a > 3) AND (b != 0) AND ((a / b) > c)
PRINT "Pass"
ELSE
PRINT "Fail"
END IF
END

A) Pass B) Fail C) ERROR D) None

You might also like