12th Standard Syllabus & Materials
12th Standard
TN 12th English Poem - 6 - Incident of the French Camp Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th English Prose - 6 - On the Rule of the Road Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th English Prose - 5 - The Chair Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th English Supplementary - 4 - The Midnight Visitor Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th English Poem - 4 - Ulysses Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th English Prose - 4 - The Summit Sample Question Papers Study Material - QB365 Set A

Published on: 03/12/2019
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.
Consider the following code
< ? php
\($\)count=12;
do{
printf(“%d squared=%d
",
\($\)count, pow(\($\)count,2));
} while(\\($\)count<4);
? >
What will be the output of the code
12 squared 141
12 squared=141
“12 squared=141”
Execution error
4.
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
5.
Loops that iterate for fixed number of times is called
Unbounded loops
Bounded loops
While loops
For loops
6.
Why looping structure is necessary in programming an uages?
7.
How do..while loop differs form other loop?
8.
Compare For loop and for each loop.
9.
Write Syntax of Do while loop in PHP.
10.
Write Syntax of For each loop in PHP.
11.
Write a PHP program to display the following
12.
Write a PHP program to display color names "using foreach" loop
13.
Differentiate While and Do while loops.
14.
Differentiate For each and While loop.
15.
Write the purpose of Looping Structure in PHP
16.
Explain the process Do while loop.
17.
Explain Looping Structure in PHP.
1.
(b)
for
2.
(d)
do..while
3.
(b)
12 squared=141
4.
(d)
None of the above
5.
(b)
Bounded loops
6.
To repeat the same block of code a given number of times, or until a certain condition is met. This can be accomplished using looping statements
7.
do...while - loops through a block of code once, and then repeats the loop as long as the specified condition is true
8.
| 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. |
9.
Syntax of Do while loop
do
{
code to be executed;
} while (condition is true);
10.
Syntax of for each loop
for each ($array as $value)
{
code to be executed;
}
11.
The number is: 1
The number is: 2
The number is: 3
The number is: 4
The number is: 5
Program:
< ?php
$ x = 1;
de {
echo "The number is: $x
";
$x++;
} while ($x < = 5);
? >
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.
| For each loop | While loop |
| (i) It provides an easy way to iterate over arrays. | (i) It is used for simple iteration logics. |
| (ii) Loop iteration depends on each KEY value pair in the Array | (ii) It executes block of code while the specified condition is true. |
| (iii) Syntax: for each (Sarray as $value) { code to be executed; } |
(iii) Syntax: while (condition is true) { code to be executed; } |
15.
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.
16.
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);
?>

17.
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 English Supplementary - 3 - The Hour of Truth (Play) Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th English Poem - 3 - All the World’s a Stage Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th English Prose - 3 - In Celebration of Being Alive Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th English Supplementary - 2 - Life of Pi 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