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: 09/10/2019
PHP Conditional Statements
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.
What will be the output of the following PHP code?
< ?php
$a="1";
switch($a)
{
case 1 :
break;
print''hi'';
case 2:
print''hello'';
break;
default:
print''hi1'';
}
? >
hihellohi1
hi
hihi1
hi1
2.
What will be the output of the following PHP code?
< ?php
$x= 1;
if($x==2)
print''hi'';
elseif($x=2)
print $x;
else
print''how are u";
? >
error
2
hi
how are u
3.
What will be the output of the following PHP code?
< ?php
if(0.1)
print''hi'';
else
print''how are u";
? >
hi
error
no output
how are u
4.
What will be the output of the following PHP code ?
< ?php
if (-100)
print “hi” ;
else
print “how are u”;
? >
how are u
hi
error
no output
5.
What will be the output of the following PHP code ?
< ?php
\($\)x = 10;
\($\)y = 20;
if (\($\)x > \($\)y + \($\)y != 3)
print “hi” ;
else
print “how are u”;
? >
how are u
hi
error
no output
6.
What will be the output of the following PHP code ?
< ?php
\($\)a = “”;
if (\($\)a)
print “all”;
else
print “some”;
? >
all
some
error
no output
7.
Statement which is used to make choice between two options and only option is to be performed is written as
if statement
if else statement
then else statement
else one statement
8.
What will be the output of the following PHP code?
< ? php
\($\) x;
if (\($\)x)
print “hi” ;
else
print “how are u”;
? >
how are u
hi
error
no output
9.
Compare if and if else statement.
10.
Write the Syntax of Switch statement.
11.
Write the usage of Switch Statement in PHP.
12.
Write the Syntax of an If ... else statement in PHP.
13.
What is the purpose of the if ... else statement?
14.
What are the different types of conditional statements in PHP?
15.
Write, a PHP program to display independenc day and republic day the greetings using If elseif else statement.
16.
Write a PHP code to display "Have a nice weekend!" if the current day is Friday, otherwise it will output "Have a nice day!" using if-else statement.
17.
Differentiate if statement and if elseif else statement.
18.
Differentiate Switch and if else statement.
19.
Write the features Conditional Statements in PHP.
20.
Explain if else statement in PHP. With an example.
21.
Explain the Function of Conditional Statements in PHP.
1.
2.
(b)
2
3.
(a)
hi
4.
(b)
hi
5.
(b)
hi
6.
(b)
some
7.
(b)
if else statement
8.
(a)
how are u
9.
| If Statement | If else Statement |
| if statement executes some code if one condition is true. | If statement executes some code if the condition is true and else part of code executes if the condition is false. |
10.
switch (n)
{
case label 1:
code to be executed if n=labeI1;
break;
case label 2:
code to be executed if n=labeI2;
break;
case label 3:
code to be executed if n=labeI3;
break;
...
default:
code to be executed if n is different from all labels;
}
11.
(i) It is used to perform different action based on different conditions.
(ii) It works the same as if statement and it can check for multiple values at a time.
12.
Syntax:
if (condition)
{
//True-block;
}
else
{
//False-block;
}
13.
The if ... else statement is a conditional statement in PHP. It executes one block of code if a condition is true and another block of code if the condition is false.
14.
There are several types of conditional statements in PHP. They are
1. 'if' statement
2. 'if...else' statement
3. 'if...elseif...else' statement
4. 'switch' statement
15.
< ?php
$x = "August";
if ($x == "January'') {
echo "Happy Republic Day";
}
elseif ($x == "August'') {
echo "Happy Independence Day!!!";
}
else{
echo "Nothing to show";
}
? >
16.
< ?php·
$d=date("D'');
if($d=="Fri'')
{
echo"Have a nice weekend!";
}
Else
{
echo"Have a nice day!";
}
? >
17.
| No. | if elseif else statement | if statement |
| 1 | If-elseif-else statement is a combination of if-else statement. | If statement executes a single statement |
| 2 | More than one statement can execute the condition based on user needs | Only one statement can execute |
| 3 | If the condition if false more alternatives are there. | If the condition is false, there is no alternative. |
18.
| Switch Statement | If else statement |
|---|---|
| Switch statement uses single expression for multiple choices. | if-else statement uses multiple statement for multiple choices. |
| It test only for equality. | It test for equality as well as for logical expression. |
| Statement will be executed is decided by user. | Evaluates any type |
| If switch statements does not match any cases, the default statements is executed. | If the condition fails, then by default the else statement is executed. |
19.
(i) Conditional statements are useful for writing decision making logics. It is the most important feature of many programming languages, including PHP.
(ii) When we write the code for conditional statements very often, we can perform different actions for different decisions in different business logic.
20.
If else statement in PHP:
If statement executes a statement or a group of statements if a specific condition is satisfied by the user expectation. When the condition gets false (fail) the else block is executed.
Syntax:
if (condition)
{
Execute statement(s) if condition is true;
}
else
{
Execute statement(s) if condition is false;
}
Example
$Pass_Mark=35;
$Student_Mark= 70;
if ($Student_Mark>= $Pass_Mark){
echo "The Student is eligible for the promotion";
}
else {
echo "The Student is not eligible for the promotion";
} ?>
21.
(i) If statement in PHP: If statement executes a statement or a group of statements if a specific condition is satisfied as per the users expectation. This is the simplest PHP's conditional statement and can be written in the following form.
Syntax:
if (condition)
{
// code to be executed if condition is true;
}
(ii) If else statement in PHP: The if statement evaluates a condition and executes a set of code if the condition is true and another set of code if the condition is false.
Syntax:
if(condition)
{
//True-block;
}
else
{
//False-block;
}
(iii) If-elseif-else statement in PHP: If-elseif-else statement is a combination of if-else statement. Here multiple conditions can be checked and action is based on the result of the condition.
Syntax:
if (Condition 1)
{
//code to be executed if condition 1 is true;
}
elseif (condition2)
{
//code to be executed if condition1 is false and condition2 is true;
}
elseif (condition3)
{
// code to be executed if condition1 and condition2 are false and condition3 is true;
}
else
{
//code to be executed if all conditions are false;
}
Switch case: The switch case is an alternative to the if.. elseif.. else statement which executes a block of code corresponding to the match.
Syntax:
switch (expression)
case value1:
//code to be executed if expression= value1; break;
case value2;
//code to beexecuted if expression = value2; break;
...
default:
//code to be executed if cexpression is not equal to any of the values;
}
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