23CSE108 PROBLEM SOLVING AND ALGORITHMIC THINKING
DEBUG/TUTORIAL-OCTOBER 2025
CIVIL ENGINEERING
SET 1
Total=10 marks
1. Identify the program and Fill in the missing statements with the appropriate one.
[5 marks)]
1️⃣ Start
2️⃣ Declare variables _________________________
3️⃣ Print "Enter a number to check whether prime or not:"
4️⃣ Read num
5️⃣ If (___________________________)
flag = 1
6️⃣ For (i = 2; ______________________; ++i)
a) If (________________________)
flag == 1
Break
7️⃣ If (flag == 0)
Print "Entered number %d is a prime number.", num
Else
Print "Entered number %d is not a prime number.", num
8️⃣ Stop
2. The following algorithm is intended to find the digital root of a number.
However, the algorithm contains logical errors and does not produce the correct
digital root when the sum of digits is greater than 9.
[5 marks]
Step 1:Start
Step 2:Declare n, sum = 0, rem
Step 3:Print "Enter a number:"
Step 4:Read n
Step 5:While n > 0
Step 5.1 rem = n % 10
Step 5.2: sum = sum + rem
Step 5.3: n = n / 10
Step 6:End While
Step7:If sum > 9 then
Step 7.1: Print "Digital root =", sum
Step 8:Else
Step 8.1: Print "Digital root =", sum
Step 9:End If
Step 10:Stop