12th Standard Syllabus & Materials
12th Standard
TN 12th Computer Applications மின்னணு தரவு பரிமாற்றம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின் - வணிக பாதுகாப்பு அமைப்புகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின்னணு செலுத்தல் முறைகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின் - வணிகம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications திறந்த மூல கருத்துருக்கள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications வலையமைப்பு வடமிடல் Sample Question Papers Study Material - QB365 Set A

Published on: 06/01/2020
Looping Structure
Download Tamil Nadu 12th Standard Computer Applications question papers, model tests, one-mark questions, important questions, and public exam papers in PDF format. Free study materials and answer keys for TN State Board students.
Questions + Answers key
Take MCQ Computer Applications Test

1.
________ loops execute a block of code a specified number of times.
foreach
for
while
do..while
2.
Which of the following is an entry check loop?
foreach
for
while
do..while
3.
The ________ construct provides an easy way to iterate over arrays
foreach
for
while
do..while
4.
What will be the output of the following PHP code ?
< ?php
for (\($\)x = -1; \($\)x < 10;--\($\)x)
{
print \($\)x;
}
? >
123456713910412
123456713910
1234567139104
Infinite loop
5.
What will be displayed in a browser when the following PHP code is executed :
< ?php
for (\($\)counter = 10; \($\)counter < 10;
\($\)counter = \($\)counter + 5){
echo “Hello”;
}
? >
Hello Hello Hello Hello Hello
Hello Hello Hello
Hello
None of the above
6.
How foreach loop will execut?
7.
Draw the For loop Structure and Flow chart
8.
How do..while loop differs form other loop?
9.
How "for loop" will execute?
10.
Explain the use of for each loop in PHP.
11.
Compare For loop and for each loop.
12.
Write a PHP program to display color names "using foreach" loop
13.
Differentiate While and Do while loops.
14.
Write the purpose of Looping Structure in PHP
15.
Write the features Looping Structure.
16.
Explain working of loops in array
17.
Explain the process Do while loop.
18.
Discuss in detail about For each loop.
19.
Explain Looping Structure in PHP.
1.
(b)
for
2.
(d)
do..while
3.
(a)
foreach
4.
(d)
Infinite loop
5.
(d)
None of the above
6.
(i) foreach loop is exclusively available In PHP.
(ii) It works only with arrays. The loop iteration deepens on each KEY Value pair in the Array
7.
8.
do...while - loops through a block of code once, and then repeats the loop as long as the specified condition is true
9.
For loops execute a block of code a specified number of times.
10.
(i) It is used to loop through each KEY value pair in an array.
(ii) It will issue an error when you try to use it on a variable with a different data type or an initialized variable.
11.
| For loop | For each loop |
|---|---|
| For loops execute a block of code a specified number of times. | The foreach construct provides an easy way to iterate over arrays. |
12.
< ?php
scolors = array("red", "qreen", "blue'; "yellew'');
fereach (sectors as $value)
{
echo "svalue < br >";
}
? >
13.
| While loop | Do while loop |
| (i) It is important feature which is used for simple iteration logics. | (i) It always run the statement inside of the loop block at the first time execution. |
| (ii) It is Entry controlled loop | (ii) It is exit controlled loop |
| (iii) It checks the condition, and executes the loop if specified condition is true. | (iii) It checks the condition, and then repeats the loop as long as the specified condition is true. |
| Syntax : While(condition) { code to be executed; } |
Syntax : do { code to be executed; } while (condition is true); |
14.
1. In Programming, the looping structure is often necessary to repeat the same block of code for a given number of times, until a certain condition is met.
2. Loop properties easy way to iterate over arrays.
3. Loop structure needed when we want to run block of code again and again.
15.
(i) PHP Loop Often when you write code, you want the same block of code to run over and over again in a row.
(ii) Instead of adding several almost equal code-lines in a script, we can use loops to perform a task.
(iii) Looping structures are useful for writing iteration logics.
(iv) It is the most important feature of many programming languages, including PHP.
16.
1. The array concepts in looping structure is used in for each loop.
2. For each loop is exclusively available in PHP. It works only with arrays.
3. The loop iteration depends on each KEY value pair in the array. In 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.
4. For each 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.
Syntax:
for each ($ array as $ value)
{
code to be executed;
}
1. The for each statement is used to loop through arrays.
2. 'For each' pass the value of the current array element is assigned to $value and the array pointer is moved by one and in the next pass next element will be processed.
Example:
$array = array (1, 2, 3);
{
echo "Value is $value
";
}
?>
Output:
Value is 1
Value is 2
Value is 3
17.
Do while loop always run the statement inside of the loop block at the first time of execution. Then it checks 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);
Example
\(\$\)Student_count = 10;
\(\$\)student_number= 1;
do
{
echo "The student number is: \(\$\)student_number
";
\(\$\)student_number++ ;
}
while(\(\$\)student_number< = \(\$\)Student_count);
?>

18.
1. The foreach statement is used to loop through arrays.
2. The loop iteration depends on KEY value pair in the array.
3. In the loop iteration, the value of the current array element is assigned to $value 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 ex
}
Examples:
for each ($student_name as $value)
{
echo $value
";
}
?>
Output:
Sriakshaya
Sriram
Srisai
Srivatchan
19.
Looping structure are useful for writing iteration logics. It is the most important feature of many programming languages including PHP.
Looping categories are
(i) for loop
(ii) for each loop
(iii) while loop
(iv) Do while loop
(i) for loop:
It 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;
}
Parameters:
init counter: To initialize the loop initial counter value
test counter : Evaluated for every iteration, of the loop.
If it evaluates to TRUE, the loop continues.
If it evaluates to FALSE, the loops ends.
Increment counter:Increases the loop counter value.
(ii) for each loop:
It works only with arrays.
Loop iteration depends on each KEY value pair in the Array.
In loop iteration, 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;
}
(iii) While loop:
It is used for simple iteration logics.
It checks the condition, if the condition is true, and it executes the loop.
Syntax:
while (condition is true)
code to be executed;
}
(iv) Do while loop:
Do while loop always run the statement inside the loop block at the first time of execution. It then checks the condition. If the specified condition is true, it executes the loop.
Syntax:
do
{
code to be executed;
}while (condition is true);
}
12th Standard Syllabus & Materials
12th Standard
TN 12th Computer Applications களப்பெயர் முறைமை (DNS) Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications வலையமைப்பு எடுத்துக்காட்டுகள் மற்றும் நெறிமுறைகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications கணினி வலையமைப்பு ஓர் அறிமுகம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications PHP-உடன் MySQL-ஐ இணைத்தல் Sample Question Papers Study Material - QB365 Set A
Tamilnadu Stateboard 12th Standard Subjects

Maths

Chemistry

Physics

Biology

Computer Science

Business Maths and Statistics

Economics

Commerce

Accountancy

History

Computer Applications

Biology

Computer Technology

Computer Applications

Computer Science

Business Maths and Statistics

Commerce

Economics

Maths

Chemistry

Physics

Computer Technology

History

Accountancy

Tamil

English

French
Tamilnadu Stateboard Standards