Students can Download Computer Applications Chapter 7 Looping Structure Questions and Answers, Notes Pdf, Samacheer Kalvi 12th Computer Applications Book Solutions Guide Pdf helps you to revise the complete Tamilnadu State Board New Syllabus and score more marks in your examinations.

Tamilnadu Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Samacheer Kalvi 12th Computer Applications Looping Structure Text Book Back Questions and Answers

PART – I
I. Choose The Correct Answer

Question 1.
Most complicated looping structure is ……………………………
(a) While
(b) Do While
(c) For
(d) None of them
Answer:
(c) For

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 2.
Loops that iterate for fixed number of times is called ………………………….
(a) Unbounded loops
(b) Bounded loops
(c) While loops
(d) For loops
Answer:
(b) Bounded loops

Question 3.
Which loop evaluates condition expression as Boolean, if it is true, it executes statements and when it is false it will terminate?
(a) For loop
(b) For each loop
(c) While loop
(d) All of them
Answer:
(d) All of them

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 4.
Which loop evaluates condition expression as Boolean, if it is true, it executes statements and when it is false it will terminate?
(a) For loop
(b) For each loop
(c) While loop
(d) All of them
Answer:
(d) All of them

Question 5.
What will be displayed in a browser when the following PHP code is executed:
<?php
for (Scounter = 20; $counter< 10;
$counter++)
{
echo “Welcome to Tamilnadu “;
}
echo “Counter is: Scounter”;
?>
(a) Welcome to Tamilnadu
(b) Counter is: 20
(c) Welcome to Tamilnadu Counter is: 22
(d) Welcome to Tamilnadu Welcome to Tamilnadu Counter is: 22
Answer:
(b) Counter is: 20

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 6.
What will be displayed in a browser when the following PHP code is executed:
<?php
for (Scounter = 10; Scounter = 10;
$counter = $counter + 5){
echo “Hello”;
}
?>
(a) Hello Hello Hello Hello Hello
(b) Hello Hello Hello
(c) Hello
(d) None of the above
Answer:
(d) None of the above

Question 7.
PHP supports four types of looping techniques?
(a) for loop
(b) while loop
(c) for each loop
(d) all the above
Answer:
(d) all the above

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 8.
Consider the following code
<? php
$count=12;
do{
printf(“%d squared=%d<br/>”,
Scount, pow($count,2));
} while($count<4);
?>
What will be the output of the code.
(a) 12 squared 141
(b) 12 squared=141
(c) “12 squared=141”
(d) Execution error
Answer:
(d) Execution error

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 9.
What will be the output of the following PHP code?
<?php
for ($x = 1; $x < 10;++$x)
{
print “*\t”;}
?>
(a) **********
(b) *********
(c) ***********
(d) Infinite loop
Answer:
(b) *********

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 10.
What will be the output of the following PHP code?
<?php
for ($x =-1; $x < 10;–$x)
{
print $x;
}
?>
(a) 123456713910412
(b) 123456713910
(c) 1234567139104
(d) Infinite loop
Answer:
(d) Infinite loop

PART – II
II. Short Answer

Question 1.
Define Looping Structure in PHP?
Looping Structure:
Answer:

  1. Looping Structures are useful for writing iteration logics.
  2. It is the most important feature of many programming languages, including PHP.
  3. They are implemented using the following categories,
    1. for Loop
    2. While Loop
    3. foreach Loop
    4. Do While Loop

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 2.
Define for loop in PHP?
Answer:
For Loop:
For loop is an important functional looping system which is used for iteration logics when the programmer know in advance how many times the loop should run.
Syntax:
for (init counter; test counter; increment counter)
{
code to be executed;
}

Question 3.
What is For each loop in PHP?
Answer:
For each Loop:

  1. for each loop is exclusively available in PHP.
  2. It works only with arrays. The loop iteration deepens on each KEY Value pair in the Array.
  3. For each, loop iteration the value of the current array element is assigned to $value variable and the array pointer is shifted by one, until it reaches the end of the array element.

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 4.
List out Looping Structure in PHP?
Answer:

  1. for Loop
  2. While Loop
  3. For each Loop
  4. Do While Loop

Question 5.
Write Syntax of For loop in PHP?
Answer:
for (init counter; test counter; increment counter)
{
code to be executed;
}

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 6.
Write Syntax of For each loop in PHP?
Answer:
for each ($array as $value)
{
code to be executed;
}

Question 7.
Write Syntax of while loop in PHP?
Answer:
while (condition is true)
{
code to be executed;
}

Question 8.
Write Syntax of Do while loop in PHP?
Answer:
do
{
code to be executed;
}
while (condition is true);

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 9.
Compare For loop and for each loop?
Answer:
For loop:
The for loop is used when you know in advance how many times the script should run.

for each loop:
The for each loop works only on arrays, and is used to loop through each key/value pair in an array.

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 10.
Usage of for each loop in PHP?
Answer:

  1. The for each loop works only on arrays,
  2. It is used to loop through each key/value pair in an array.

PART – III
III. Explain in Brief Answer

Question 1.
Write the features Looping Structure?
Looping Structure:
Answer:

  1. Looping Structures are useful for writing iteration logics.
  2. It is the most important feature of many programming languages, including PHP.
  3. They are implemented using the following categories:
    1. For Loop
    2. For each Loop
    3. while Loop
    4. Do while Loop

1. For Loop:
For loop is an important functional looping system which is used for iteration logics when the programmer know in advance how many times the loop should run.
Syntax:
for (init counter; test counter; increment counter) {
code to be executed;
}

2. For each Loop:
foreach loop is exclusively available in PHP. It works only with arrays. The loop iteration deepens on each KEY Value pair in the Array. For each, loop iteration the value of the current array element is assigned to $value variable and the array pointer is shifted by one, until it reaches the end of the array element.
Syntax:
for each ($array as $value)
{
code to be executed;
}

3. While Loop:
While loop is an important feature which is used for simple iteration logics. It is checking the condition whether true or false. It executes the loop if specified condition is true.
Syntax:
while (condition is true)
{
code to be executed;
}

4. Do While Loop:
Do whileloop always run the statement inside of the loop block at the first time execution. Then it is checking the condition whether true or false. It executes the loop, if the specified condition is true.
Syntax: do
{
code to be executed;
}
while (condition is true);

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 2.
Discuss in detail about For each loop?
Answer:
For each Loop:
foreach loop is exclusively available in PHP. It works only with arrays. The loop iteration deepens on each KEY Value pair in the Array. For each, loop iteration the value of the current array element is assigned to $value variable and the array pointer is shifted by one, until it reaches the end of the array element.
Syntax:
for each ($array as Svalue)
{
code to be executed;
}
The foreach construct provides an easy way to iterate over arrays, foreach works only on arrays and objects, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable.
Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure
Example:
<?php
$Student_name = array(“Magilan”, “Iniyan”,
“Nilani”, “Sibi”, “Shini”);
foreach (SStudent_name as $value)
{
echo “Svalue <br>”;
}
?>

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 3.
Explain the process Do while loop?
Do While Loop:
Answer:
Do while loop always run the statement inside of the loop block at the first time execution. Then it is checking the condition whether true or false. It executes the loop, if the specified condition is true.
Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure
Syntax:
do
{
code to be executed;
}
while (condition is true);
Example:
<?php
$Student_count = 10;
$student_number=1;
do
{
echo “The student number is: $student_number<br>”;
$ student_number++;
}
while($student_number<= $Student_count)
?>

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 4.
Explain concepts of for loop with example?
Answer:
For Loop:
For loop is an important functional looping system which is used for iteration logics when the programmer know in advance how many times the loop should run.

Syntax:
for Unit counter; test counter; increment counter)
{
code to be executed;
}

Parameters:

  1. init counter: Initialize the loop initial counter value
  2. Test counter: Evaluated for every iteration of the loop. If it evaluates to TRUE, the loop continues. If it evaluates to FALSE, the loop ends.
  3. Increment counter: Increases the loop counter value.

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure
Example:
<?php
for ($i = 0; $i<= 10; $i++)
{
echo “The number is: $i<br>”;
}
?>

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 5.
Explain array concepts in Looping Structure?
Answer:
Foreach Loop:
for each loop is exclusively available in PHP. It works only with arrays. The loop iteration deepens on each KEY Value pair in the Array. For each, loop iteration the value of the current array element is assigned to $value variable and the array pointer is shifted by one, until it reaches the end of the array element.
Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure
Syntax:
for each ($array as Svalue)
{
code to be executed;
}
The for each construct provides an easy way to iterate over arrays, foreach works only on arrays Foreach loop Structure and Flow and objects, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable.
Example:
<?php
$Student_name = array(“Magilan”, “Iniyan”,
“Nilani”, “Sibi”, “Shini”);
foreach (SStudentname as Svalue) {
echo “Svalue <br>”;
}
?>

Samacheer Kalvi 12th Computer Applications Solutions Looping Structure Additional Question and Answer

1. Choose The Best Answer

Question 1.
………………………….. structures are useful for writing iteration logics.
Answer:
Looping

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 2.
Which loop is used if you know in advance how many times the loop should run?
(a) For
(b) For each
(c) While
(d) Do-while
Answer:
(a) For

Question 3.
Find the true statement from the following.
(a) Init counter initialises the loop
(b) Increment counter initialises the loop
Answer:
(a) Init counter initialises the loop

Question 4.
Which counter decides whether the loop should continue or ends?
(a) Init
(b) Test
(c) Increment
(d) Decrement
Answer:
(b) Test

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 5.
How many segments are there in a for loop?
(a) 1
(b) 2
(c) 3
(d) 4
Answer:
(c) 3

Question 6.
Pick the odd one out related to the parameters of the for loop?
(a) init
(b) test
(c) text
(d) Increment
Answer:
(c) text

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 7.
How many types of loops are there?
(a) 1
(b) 2
(c) 3
(d) 4
Answer:
(d) 4

Question 8.
Each segment of the for loop is terminated by
(a) ,
(b) ;
(c) :
(d) .
Answer:
(b) ;

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 9.
Which loop is exclusively available in PHP?
(a) For
(b) While
(c) for each
(d) do while
Answer:
(c) for each

Question 10.
Which of the following loop works only with arrays?
(a) for
(b) while
(c) for each
(d) do while
Answer:
(c) for each

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 11.
Find the Incorrect statement
(I) For loop works only with arrays
(II) For each loop works only with arrays
Answer:
(I) For loop works only with arrays

Question 12.
Which one of the following loop has key value pair?
(a) for
(b) for each
(c) while
(d) do.while
Answer:
(b) for each

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 13.
Assertion (A): In for each loop, the array pointer is shifted by one.
Reason (R): Whether it reaches the end of the array element
(a) A is True, R is correct But R is not correct explanation for A
(b) Assertion is True, Reason is False
(c) Assertion is false, Reason is true
(d) Assertion and Reason are correct and R is the correct reason for A.
Answer:
(d) Assertion and Reason are correct and R is the correct reason for A.

Question 14.
Find the Wrong statement
(a) For each works on arrays and pointers
(b) For each works on arrays
(c) For each works on arrays and objects .
(d) For each works on objects
Answer:
(a) For each works on arrays and pointers

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 15.
Find the correct statement from the following.
(a) For each can be used for variables with a different data type
(b) For each can be used with uninitialized variable
(c) For each can be used for objects
Answer:
(c) For each can be used for objects

Question 16.
Which loop is used for simple iteration objects?
(a) For
(b) For each
(c) While
(d) do..while
Answer:
(c) While

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 17.
Which one of the following loop will be executed atleast once?
(a) For
(b) For each
(c) While
(d) do..while
Answer:
(d) do..while

II. Short Answer

Question 1.
Explain about the parameters in the for loop?
Answer:
Parameters:

  1. init counter: Initialize the loop initial counter value
  2. Test counter: Evaluated for every iteration of the loop. If it evaluates to TRUE, the loop continues. If it evaluates to FALSE, the loop ends.
  3. Increment counter: Increases the loop counter value.

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 2.
Give the flow chart for For Loop?
Answer:
Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 3.
Write a php program to print the students name in the array?
Example:
Answer:
<?php
$Student_name = array(“Magilan”, “Iniyan”,
“Nilani”, “Sibi”, “Shini”);
foreach ($Studentname as $value) { echo “Svalue <br>”;
?>

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 4.
Give the structure and flow for while loop?
Answer:
Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 5.
Give the structure and flow chart for dowhile loop?
Answer:
Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure

Question 6.
Write a php program to print star (*) in a single line?
Answer:
<?php
for ($x = 1; $x < 10;++$x)
{
print “*\t”;}
?>

III. Explain in detail

Question 1.
Explain While loop?
Answer:
While Loop:
While loop is an important feature which is used for simple iteration logics. It is checking the condition whether true or false. It executes the loop if specified condition is true.
Samacheer Kalvi 12th Computer Applications Solutions Chapter 7 Looping Structure
Syntax:
while (condition is true) {
code to be executed;
}
Example:
<?php
$Student_count = 10;
$student_number=1;
while($student_number<= $Student_count)
{
echo “The student number is: $student_number<br>”;
$student_number++;
}
?>

Leave a Reply

Your email address will not be published. Required fields are marked *