Empowering Students with AI-Powered Assessments & Intelligent Learning
Chapter Exam

Chapter 7: Loops in PHP — Online MCQ Test

COMPUTER APPLICATIONS · CLASS 12th · Tamil Nadu State Board

Practice Chapter 7: Loops in PHP with a free chapter-wise online MCQ test for Tamil Nadu State Board CLASS 12th COMPUTER APPLICATIONS. This chapter covers: Exploring iterative execution this chapter details looping structures in PHP scripts. Students master for loops while loops do-while loops and foreach loops specifically tailored f.... AI-generated questions from basic to board-exam level, with instant results and explanations.

10
Questions
20m
Time Limit
3
Attempts Left
  • 10 random questions from this chapter (mixed difficulty)
  • Questions you've seen before won't repeat until the pool resets
  • You have 20 minutes — exam auto-submits when time is up
  • Maximum 3 attempts per chapter
  • Results and explanations shown immediately after submission
Login to Start This Exam →

New here? Register free — includes 3 free chapter exams.

Chapter 7: Loops in PHP — Important Questions & Answers (FAQ)

Frequently asked questions from Tamil Nadu State Board CLASS 12th COMPUTER APPLICATIONS — Chapter 7: Loops in PHP, with answers and explanations. These are sample questions; the exam has its own separate question set.

Which loop in PHP is best suited for repeating a block of code a fixed number of times?
  • A. for loop ✓
  • B. while loop
  • C. do-while loop
  • D. foreach loop
Answer: A. for loop
The for loop is used when the number of iterations is known in advance. It has initialization, condition, and increment/decrement parts.
Which loop executes the block of statements at least once, even if the condition is false?
  • A. for loop
  • B. while loop
  • C. do-while loop ✓
  • D. foreach loop
Answer: C. do-while loop
In a do-while loop, the condition is checked after the loop body executes. So the body runs at least once.
Which of the following is the correct syntax of a for loop in PHP?
  • A. for(initialization; condition; increment) { statements; } ✓
  • B. for(condition; initialization; increment) { statements; }
  • C. for{ initialization; condition; increment; statements; }
  • D. for(initialization, condition, increment) { statements; }
Answer: A. for(initialization; condition; increment) { statements; }
The standard PHP for loop syntax includes initialization, condition, and increment/decrement in that order inside parentheses.
Which loop is most appropriate when the number of elements in an array is not known in advance?
  • A. for loop
  • B. while loop
  • C. foreach loop ✓
  • D. do-while loop
Answer: C. foreach loop
Foreach automatically handles every element in an array without requiring the programmer to know the size beforehand.
What is the output of the following code? $arr = array(10, 20, 30); foreach($arr as $value) { echo $value . ' '; }
  • A. 10 20 30 ✓
  • B. 30 20 10
  • C. 10,20,30
  • D. 123
Answer: A. 10 20 30
Foreach traverses the array from the first element to the last element. Each value is echoed in order with a space.

Choose Your Plan & Start Practising

All plans cover every subject and chapter of your registered grade.

Free
₹0
3 exams · 1 year
Start Free →
Active
₹350
12 exams · 1 year
Get Active →
Pro
₹899
Unlimited exams · 1 year
Get Pro →

Compare all plans in detail →