<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TN Board 12th Computer Applications Important Questions Chapter 6 &#8211; Samacheer Kalvi</title>
	<atom:link href="https://samacheer-kalvi.com/tag/tn-board-12th-computer-applications-important-questions-chapter-6/feed/" rel="self" type="application/rss+xml" />
	<link>https://samacheer-kalvi.com</link>
	<description>Tamilnadu State Board Text Books Solutions for Class 3 to 12</description>
	<lastBuildDate>Tue, 12 Oct 2021 11:19:51 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.5</generator>
<site xmlns="com-wordpress:feed-additions:1">196241473</site>	<item>
		<title>TN Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements</title>
		<link>https://samacheer-kalvi.com/tn-board-12th-computer-applications-important-questions-chapter-6/</link>
					<comments>https://samacheer-kalvi.com/tn-board-12th-computer-applications-important-questions-chapter-6/#respond</comments>
		
		<dc:creator><![CDATA[Prasanna]]></dc:creator>
		<pubDate>Mon, 11 Oct 2021 22:45:14 +0000</pubDate>
				<category><![CDATA[Important Questions]]></category>
		<category><![CDATA[PHP Conditional Statements]]></category>
		<category><![CDATA[TN Board 12th Computer Applications Important Questions Chapter 6]]></category>
		<guid isPermaLink="false">https://samacheer-kalvi.com/?p=46185</guid>

					<description><![CDATA[TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements Question 1. When is a conditional statement ended with end if? Answer: When the original it was followed by and then the code block without braces. Question 2. What will be the values of $a and $b after the code below is executed? Answer: $a = &#8216;1&#8217;; $b = &#38;$a; Sb = &#8220;2$b; output: &#8220;21&#8221; (Both $a and $b will be equal to the string &#8220;21&#8221; after the above code is executed) Question 3. Draw flow chart if elseif&#8230;else statement. Answer: (i) This flow chart explain if, elseif&#8230;else statement, it used to take decision based on the different condition. (ii) If condition is true, the following conditional code will be executed, if it is false exit from the conditional code. Question 4. Write a PHP program to find bigger, smaller, equal of any two number. Answer: &#60;? php if ($a&#62;$b) { }echo &#8220;A is bigger than B&#8221;; else if ($a = = $b) { echo &#8220;A is equal toB&#8221;; } else { echo &#8220;A is smaller than B&#8221;; } . ?&#62; Question 5. What is faster if or switch statement? Answer: A switch statement might prove to &#8230;]]></description>
										<content:encoded><![CDATA[<h2>TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements</h2>
<p>Question 1.<br />
When is a conditional statement ended with end if?<br />
Answer:<br />
When the original it was followed by and then the code block without braces.</p>
<p>Question 2.<br />
What will be the values of $a and $b after the code below is executed?<br />
Answer:<br />
$a = &#8216;1&#8217;;<br />
$b = &amp;$a;<br />
Sb = &#8220;2$b;<br />
output: &#8220;21&#8221;<br />
(Both $a and $b will be equal to the string &#8220;21&#8221; after the above code is executed)</p>
<p>Question 3.<br />
Draw flow chart if elseif&#8230;else statement.<br />
Answer:</p>
<p><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-46187" src="https://samacheer-kalvi.com/wp-content/uploads/2021/09/TN-State-Board-12th-Computer-Applications-Important-Questions-Chapter-6-PHP-Conditional-Statements-1.png" alt="TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements 1" width="303" height="288" srcset="https://samacheer-kalvi.com/wp-content/uploads/2021/09/TN-State-Board-12th-Computer-Applications-Important-Questions-Chapter-6-PHP-Conditional-Statements-1.png 303w, https://samacheer-kalvi.com/wp-content/uploads/2021/09/TN-State-Board-12th-Computer-Applications-Important-Questions-Chapter-6-PHP-Conditional-Statements-1-300x285.png 300w" sizes="(max-width: 303px) 100vw, 303px" /></p>
<p>(i) This flow chart explain if, elseif&#8230;else statement, it used to take decision based on the different condition.<br />
(ii) If condition is true, the following conditional code will be executed, if it is false exit from the conditional code.</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 4.<br />
Write a PHP program to find bigger, smaller, equal of any two number.<br />
Answer:<br />
&lt;? php<br />
if ($a&gt;$b)<br />
{<br />
}echo &#8220;A is bigger than B&#8221;;<br />
else if ($a = = $b)<br />
{<br />
echo &#8220;A is equal toB&#8221;;<br />
}<br />
else<br />
{<br />
echo &#8220;A is smaller than B&#8221;;<br />
} .<br />
?&gt;</p>
<p>Question 5.<br />
What is faster if or switch statement?<br />
Answer:</p>
<ol>
<li>A switch statement might prove to be faster than if provided number of cases are good.</li>
<li>If-else better for boolean values whereas switch statements are great for fixed data values.</li>
<li>If-else statement can test expressions based on the ranges of values or conditions, whereas a switch statement tests expressions based only on a single integer, enumerated value, or string object.</li>
</ol>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 6.<br />
Explain the following conditional statement PHP coding.<br />
Answer:<br />
&lt;! DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;? php<br />
$S = date (&#8220;D&#8221;);<br />
if ($S &lt; &#8220;15&#8221;) *<br />
{<br />
echo &#8220;working day&#8221;;<br />
}<br />
?&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
Output: Working day<br />
Explanation of code:<br />
1. &lt;? PHP . &#8211; starting php<br />
2 . Ss = date(&#8220;D&#8221;-) &#8211; Declaring variable<br />
3. if ($S &lt; &#8220;15&#8221;) &#8211; If condition true code executes<br />
4. echo &#8211; Built in function to print the text<br />
5. ?&gt; &#8211; closing of php</p>
<p>Question 7.<br />
Write a simple php program to print grade of the student result using if&#8230; elseif&#8230;else conditional statement.<br />
Answer:<br />
coding:<br />
&lt;?php<br />
$ result = 70;<br />
if ($result &gt; = 75)<br />
{<br />
echo &#8220;Grade A&#8230;Pass&#8221;;<br />
}<br />
elseif ($result &gt; = 60)<br />
{<br />
echo &#8220;Grade B&#8230;Pass&#8221;;<br />
}<br />
elseif ($result &gt; = 45)<br />
{<br />
echo &#8220;Grade C pass&#8221;;<br />
}<br />
else<br />
{<br />
echo &#8220;Fail&#8221;;<br />
}<br />
?&gt;</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 8.<br />
Write a php program using switch case for string variable.<br />
Answer:<br />
$position = &#8220;dba&#8221;;<br />
switch ($position)<br />
{<br />
case &#8220;member&#8221;:<br />
echo &#8220;welcome member&#8221;;<br />
break;<br />
case &#8220;teacher&#8221;:<br />
echo &#8220;welcome teacher&#8221;;<br />
break;<br />
case &#8220;student&#8221;:<br />
echo &#8220;welcome student&#8221;;<br />
break;<br />
default:<br />
echo &#8220;Welcome you all others&#8221;;<br />
break;<br />
}</p>
<p>Question 9.<br />
Why switch statement is better for multi-way branching.<br />
Answer:</p>
<ol>
<li>When compiler compiles a switch statement, if will inspect each of the case constants and create a jump table.</li>
<li>A jump table that will use for selecting the path of execution depending on the value of the expression.</li>
<li>Therefore, if we need to select among a large group of values, a switch statement will run much faster than the equivalent logic coded using a sequence of if&#8230;elses.</li>
<li>The compiler can do this because it knows that the case constants are all the same type and simply must be compared for equality with the switch expression.</li>
<li>While in case of it expressions, the compiler has no such knowledge.</li>
</ol>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 10.<br />
Write a PHP program to check given character is vowel or consonant using if&#8230;else if statement.<br />
Answer:<br />
&lt;? php<br />
$char = $_post [ &#8216;ch&#8217;]; ,<br />
if ($char==&#8221;a&#8221;) &#8216;<br />
{<br />
echo $char.&#8221;is vowel&#8221;;<br />
}<br />
elseif ($char==&#8221;e&#8221;)<br />
{<br />
echo $char.&#8221;is vowel&#8221;;<br />
}<br />
elseif ($char==&#8221;iM)<br />
{<br />
echo $char .&#8221;is vowel&#8221;;<br />
elseif ($char==&#8221;o&#8221;)<br />
{<br />
echo $char. &#8220;is vowel&#8221;;<br />
}<br />
elseif ($char==&#8221;u&#8221;)<br />
{<br />
echo $char.&#8221;is vowel&#8221;;<br />
}<br />
else<br />
{<br />
echo $char. &#8220;is consonant&#8221;;<br />
}<br />
?&gt;</p>
<p>Question 11.<br />
Write a PHP program a day of the week using if&#8230;elseif&#8230;else statement.<br />
Answer:<br />
&lt;?php<br />
if ($day==&#8221;Mon&#8221;) &#8216;<br />
echo &#8220;Monday&#8221;;<br />
elseif ($day==&#8221;Tue&#8221;)<br />
echo &#8220;Tuesday&#8221;;<br />
elseif ($day==&#8221;Wed&#8221;)<br />
echo &#8220;WEDNESDAY&#8221;;<br />
elseif ($day==&#8221;Thu&#8221;)<br />
echo &#8220;THURSDAY&#8221;;<br />
elseif ($day==&#8221;Fri&#8221;)<br />
echo &#8220;FRIDAY&#8221;;<br />
elseif ($day==&#8221;Sat&#8221;)<br />
echo &#8220;SATURDAY&#8221;;<br />
else<br />
echo &#8220;SUNDAY&#8221;;<br />
?&gt;</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 12.<br />
Write a PHP program day of the week using switch case statement.<br />
Answer:<br />
&lt;?php<br />
$today=date(&#8220;D&#8221;);<br />
switch ($today)<br />
&lt;<br />
case &#8220;Mon&#8221;:<br />
echo &#8220;Today is Monday&#8221;;<br />
break; ’<br />
case &#8220;Tue&#8221;:<br />
echo &#8220;Today is Tuesday&#8221;; .<br />
break;<br />
case &#8220;Wed&#8221;:<br />
echo &#8220;Today is Wednesday&#8221;;<br />
break;<br />
case &#8220;Thu&#8221;<br />
echo &#8220;Today is Thursday&#8221;;<br />
break;<br />
case &#8220;fri&#8221;<br />
echo &#8220;Today is Friday&#8221;;<br />
break; &#8216;<br />
case &#8220;sat&#8221;<br />
echo &#8220;Today is Saturday&#8221;;<br />
break;<br />
case &#8220;sun&#8221;:<br />
echo &#8220;Today is Sunday&#8221;;<br />
break;<br />
default:<br />
echo &#8220;Thank you&#8221;; break;<br />
}<br />
?&gt;</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 13.<br />
Define Conditional Statements in PHP.<br />
Answer:<br />
Conditional statements in PHP are useful writing decision making logics. It is most important feature of many programming language.</p>
<p>Question 14.<br />
Define if statement in PHP.<br />
Answer:<br />
If statement is a conditional branching statement. If statement executes a statement or a group of statements if a specific condition is satisfied as per the user expectation.</p>
<p>Question 15.<br />
What is if else statement in PHP?<br />
Answer:<br />
If&#8230; else statement in PHP is the if statement executes a statement or a group of statements if a specific condition is satisfied by the user expectation. When the condition gets falls the else block is executed.</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 16.<br />
List out Conditional Statements in PHP.<br />
Answer:<br />
The conditional statements in PHP are<br />
if statement, if&#8230;else statement,<br />
if&#8230; elseif&#8230; else statement, switch statement.</p>
<p>Question 17.<br />
Write Syntax of the If else statement in PHP.<br />
Answer:<br />
Syntax:<br />
if (condition)<br />
{<br />
Execute statement(s) if condition is true;<br />
}<br />
else<br />
{<br />
Execute statement(s) if condition is false;<br />
}</p>
<p>Question 18.<br />
Define if&#8230;elseif&#8230;.else Statement in PHP.<br />
Answer:<br />
If &#8230; elseif&#8230; else statement in PHP is a combination of if&#8230;else statement. More than one statement can execute the condition based on user needs.</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 19.<br />
Usage of Switch Statement in PHP.<br />
Answer:</p>
<ol>
<li>The switch statement is used to perform different actions based on different conditions.</li>
<li>Switch statement works the same as if statements but they can check for multiple values at a time.</li>
</ol>
<p>Question 20.<br />
Write Syntax of Switch statement.<br />
Answer:<br />
Syntax:<br />
Switch (n)<br />
{<br />
case label 1:<br />
code to be executed if n = label 1;<br />
break;<br />
case label 2:<br />
code to be executed if n = label 2;<br />
break;<br />
case label 3:<br />
code to be executed if n = label 3;<br />
break;<br />
&#8212;&#8212;&#8211;<br />
&#8212;&#8212;&#8211;<br />
default:<br />
code to be executed if n is different from all labels;<br />
}</p>
<p>Question 21.<br />
Compare if and if else statement.<br />
Answer:</p>
<table border="2">
<tbody>
<tr>
<td style="text-align: center;" width="312">If statement</td>
<td width="312">
<p style="text-align: center;"> If&#8230; else statement</p>
</td>
</tr>
<tr>
<td width="312">The if statement is used to execute a block of code only if the specified condition evaluates to true.</td>
<td width="312"> The if&#8230;else statement allows you to execute one block of code if the specified condition is evaluates to true and another block of code if it is evaluates to false.</td>
</tr>
<tr>
<td width="312">The if statement is quite basic because in if statement output will display when condition must be true, if condition is false it display nothing.</td>
<td width="312"> If&#8230;else statements allows you to display output in both the conditions, that is if condition is true display some message otherwise display other message.</td>
</tr>
</tbody>
</table>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 22.<br />
Write the features Conditional Statements in PHP.<br />
Answer:</p>
<ol>
<li>PHP programmers evaluate different conditions during of a program and take decisions based on whether these conditions evaluate to true or false.</li>
<li>if statement &#8211; executes some code if one condition is true.</li>
<li>if., .else statement &#8211; executes some code if a condition is true and another code if that condition is false.</li>
<li>if&#8230;elseif&#8230; else statement &#8211; executes different codes for more than two conditions.</li>
<li>Switch statement &#8211; selects one of many blocks of code to be executed.</li>
</ol>
<p>Question 23.<br />
Write the purpose of if elseif else statement.<br />
Answer:</p>
<ol>
<li>When we want to execute different code for different set of conditions, and we have more than two possible conditions, then we use if&#8230;elseif&#8230; else statement.</li>
<li>We have also used logical operator are very useful while writing multiple condition if statement.</li>
<li>When use if&#8230;elseif&#8230;else statement as many as you want, each condition inside if ( ) can accept logical operators like AND, OR, NOT.</li>
<li>If&#8230; elseif&#8230;else statement is a combination of if-else statement.</li>
</ol>
<p>Question 24.<br />
Differentiate Switch and if else statement.<br />
Answer:</p>
<table border="2">
<tbody>
<tr>
<td width="312">
<p style="text-align: center;">Switch statement</p>
</td>
<td width="312">
<p style="text-align: center;"> if&#8230;else statement</p>
</td>
</tr>
<tr>
<td width="312">Switch statement is to use when the same value is compared against a set. of values.</td>
<td width="312"> If&#8230;else can be used for any occasion where comparison need to be done.</td>
</tr>
<tr>
<td width="312">In switch statement usually there are no conditions to evaluate, it can bit efficient over an elseif counter part.</td>
<td width="312"> Each if statement checks a condition and operands associated with the condition can be different from one if to another attached elseif.</td>
</tr>
<tr>
<td width="312">The switch statements work the same as if statements but they can check for multiple values at a time.</td>
<td width="312"> The if statement is a way to make decision based upon the result of a condition.</td>
</tr>
</tbody>
</table>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 25.<br />
Write Short notes on Switch statement.<br />
Answer:<br />
(i) Use the switch statement to select one of many blocks of code to be executed.<br />
(ii) The switch statement is used to perform different action based on different conditions.<br />
Syntax:<br />
switch (n)<br />
{<br />
case label 1:<br />
code to be executed if n = label 1;<br />
break;<br />
case label 2:<br />
code to be executed if n = label 2;<br />
break;<br />
case lebel 3;<br />
code to be executed if n = label 3;<br />
break;<br />
default:<br />
code to be executed if n is different from all blocks;<br />
}<br />
(iii) The switch statements work the same as if statements but they can check for multiple values at a time.<br />
(iv) The break statement is used to prevent the code from running into the next case automatically.<br />
(v) The default statement is used if no match is found.</p>
<p>Question 26.<br />
Differentiate if statement and if elseif else statement.<br />
Answer:</p>
<table border="2">
<tbody>
<tr>
<td style="text-align: center;" width="312">if statement</td>
<td width="312">
<p style="text-align: center;"> if&#8230;elseif&#8230;else statement</p>
</td>
</tr>
<tr>
<td width="312">The if statement is used to execute a block of code only if the specified condition evaluates to true.</td>
<td width="312">The if&#8230;elseif&#8230;else is a special statement that is used to combine multiple if&#8230;else statement.</td>
</tr>
<tr>
<td width="312">If statement executes a statement if a specific condition is satisfied as per the user expectation.</td>
<td width="312">If&#8230;elseif&#8230;else statement is a combination of if &#8211; else statement.</td>
</tr>
<tr>
<td width="312">If statement is used simple decision making logics.</td>
<td width="312">If&#8230;elseif&#8230;else statement is more than one statement can execute the condition based on user needs.</td>
</tr>
</tbody>
</table>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 27.<br />
Explain Function Conditional Statements in PHP.<br />
Answer:<br />
The PHP conditional statements are &#8211;<br />
(i) If statement<br />
(ii) If&#8230;else statement<br />
(iii) If&#8230;elseif&#8230; else statement<br />
(iv) Switch statement</p>
<p>(i) If statement:<br />
This statement executes a statement or a group of statements if a specific condition is satisfied as per the user expectation.<br />
Syntax:<br />
if (condition)<br />
{<br />
Execute statements if condition is true;<br />
}<br />
Eg:<br />
&lt;?php<br />
$pass_mark = 35;<br />
$student_mark =70;<br />
if ($student_mark &gt; = $pass_mark)<br />
{<br />
echo &#8220;The student is eligible for promotion&#8221;;<br />
}<br />
?&gt;</p>
<p>(ii) If&#8230;else statement:<br />
This statement executes a statement or a group of statements if a specific condition is satisfied by the user expectation. When the condition gets false the else block is executed.<br />
Syntax:<br />
if (condition)<br />
{<br />
Execute statement(s) if condition is true;<br />
}<br />
else<br />
{<br />
Execute statement(s) if condition is false;<br />
)<br />
Eg:<br />
&lt;?php<br />
$pass_mark = 35;<br />
$student_mark = 70;<br />
if ($student_mark &gt; = $pass_mark)<br />
{<br />
echo &#8220;The student passed&#8221;;<br />
}<br />
else<br />
{<br />
echo &#8220;The student failed&#8221;;<br />
}<br />
?&gt;</p>
<p>(iii) If&#8230;elseif&#8230; else statement:<br />
This statement is a combination of if ..else statement. More than one statement can execute the condition based on user needs..<br />
Syntax:<br />
if (condition-1)<br />
{<br />
Execute statements if condition is true;<br />
}<br />
elseif (condition-2)<br />
{<br />
Execute statements if condition is true;<br />
}<br />
else<br />
{<br />
Execute statements if both conditions are false;<br />
}<br />
Eg:<br />
&lt;?php<br />
$pass_mark = 35;<br />
$first_class = 60;<br />
$student_mark =70;<br />
if ($student_mark &gt; = $first_class)<br />
{<br />
echo &#8220;The student passed with first class&#8221;;<br />
}<br />
elseif ($student_mark &gt; = $pass_mark.)<br />
{<br />
echo &#8220;The student passed&#8221;;<br />
}<br />
else<br />
{<br />
echo &#8220;The student failed&#8221;;<br />
}<br />
?&gt;</p>
<p>(iv) Switch statement:<br />
Refer III- Q.No &#8211; 4</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 28.<br />
Discuss in detail about Switch statement with an example.<br />
Answer:<br />
The switch statement is used to perform different actions based on different conditions.<br />
Syntax:<br />
switch(n)<br />
{<br />
case label 1:<br />
code to be executed if n = label 1;<br />
break;<br />
case label 2:<br />
code to be executed if n = label 2;<br />
break;<br />
case label 3:<br />
code to be executed if n = label 3;<br />
break;<br />
default:<br />
code to be executed if n is different from all labels;<br />
}</p>
<p>Eg:<br />
&lt;?php<br />
&#8221; $f col.br = &#8220;red&#8221;;<br />
switch ($fcolor)<br />
{<br />
case &#8220;red&#8221;;<br />
echo &#8220;my favourite color is red&#8221;;<br />
break;<br />
case &#8220;blue&#8221;;<br />
echo &#8220;my favourite color is blue&#8221;;<br />
break;<br />
case &#8220;green&#8221;:<br />
echo &#8220;my favourite color is greeh&#8221;;<br />
break;<br />
default:<br />
echo &#8220;my favourite color is neither Red, Blue, nor<br />
green!&#8221;;<br />
}<br />
?&gt;</p>
<p>Question 29.<br />
Explain the process Conditional Statements in PHP?<br />
Answer:<br />
(i) PHP lets programmers evaluate different conditions during process of a program and take decisions based on whether these conditions evaluate to true or false.<br />
(ii) These conditions, and the actions associated with them, are expressed by means of a programming construct called a process conditional statement. PHP supports different types of process conditional statements.<br />
(a) The if statement: In if statements output will appear when only condition must be true.<br />
(b) The if&#8230;else statement: If-else statements allows you to display output in both the condition if condition is true or. false.<br />
(c) The if&#8230;elseif&#8230;else statement: The if&#8230;elseif&#8230;else statement lets you chain together multiple if-else statements, thus allowing the programmer to define actions for more than just two possible outcomes.<br />
(d) The switch statement: The switch statement is similar to a series of if statements on the same expression.</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 30.<br />
Explain concepts of if&#8230; elseif&#8230; else statement.<br />
Answer:<br />
If&#8230;elseif&#8230;else statement is a combination of If&#8230;else statement. More than one statement can execute the condition based on user needs.<br />
The if&#8230;elseif&#8230;else statement is a special statement that is used to combine multiple if., else statements.<br />
If&#8230;elseif&#8230;else statement is more than one statement can execute the condition based on user needs.<br />
Syntax:<br />
If(condition-1)<br />
{<br />
Execute statements if condition is true;<br />
}<br />
elseif (condition-2)<br />
{<br />
Execute statements if 2nd condition is true;<br />
}<br />
else<br />
{<br />
Execute statements if both condition are false;<br />
}</p>
<p>Eg:<br />
&lt;?php<br />
$pass_mark =35;<br />
$first_class = 60;<br />
$student_mark =70;<br />
if ($student_mark&gt; = $first_class)<br />
{<br />
echo &#8220;The student passed with first class&#8221;;<br />
}<br />
elseif ($student_mark &gt; = $pass_mark)<br />
{<br />
echo &#8220;The student passed&#8221;;<br />
}<br />
else<br />
{<br />
echo &#8220;The student failed&#8221;;<br />
}<br />
?&gt;</p>
<p>Question 31.<br />
Explain if else statement in PHP.<br />
Answer:<br />
If&#8230;else statement executes a statement or a group of statements if a specific condition is satisfied by the user expectation. When the condition gets false &#8216; the else block is executed.<br />
If&#8230;else can be used for any occasion where comparison need to be done.<br />
If&#8230;else statement is a way to make decision based upon the result of a condition.<br />
Syntax:<br />
if (condition)<br />
{<br />
Execute statement(s) if condition is true;<br />
}<br />
else<br />
Execute statement(s) if condition is false;<br />
}<br />
Eg:<br />
&lt;?php<br />
$pass_mark = 35; .<br />
$student_mark = 70;<br />
if ($student_mark&gt; = pass_mark)<br />
{<br />
echo &#8220;The student passed&#8221; ;<br />
}<br />
else<br />
echo &#8220;The student failed&#8221;<br />
}<br />
?&gt;</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 32.<br />
Create simple decision making scenario using if else statement in student management application.<br />
Answer:<br />
If&#8230;else:<br />
If it raining outside, you don’t have to water the plants by yourself. So you can tell. If it is raining, I shall not water the plants, else I have to water them. So .now, we can write pseudo code.<br />
if (raining==true)<br />
do not water<br />
else<br />
do water .</p>
<p>Nested if&#8230;else:<br />
If a boy is more than 13 years old, we call him teenager. If he is more than 21 years old, he is eligible for marriage. Using nested If&#8230;else.</p>
<p>If a boy is less than 13 years old he is not a teenager, else if he is less than 21 . years old he is not eligible for marriage else he is eligible.</p>
<p>Pseudo code:<br />
If (age &lt; 13)<br />
&#8220;Not a Teenager&#8221;<br />
else<br />
{ if (age &lt; 21)<br />
&#8220;Not a eligible for marriage&#8221;<br />
else<br />
&#8220;eligible for marriage&#8221;<br />
}</p>
<p>Question 33.<br />
Explain real world usages in using Conditional Statements.<br />
Answer:<br />
A conditional statement is a statement that is stated in if&#8230; then format. This kind of statement is kind of statement is something that is often used to write a hypothesis in science.</p>
<p>The hypothesis can be created before a test is ever imagined, and the test is then designed to test the hypothesis. On the otherhand, the text might be known, and the conditional statement is then used to predict the outcome of the experiment.</p>
<p>Example I:<br />
If you believe “money can’t buy happiness”<br />
then<br />
you’re not “spending it correctly”.</p>
<p>Example II:<br />
If ”a person spends the money on himself”,<br />
then<br />
“he will be happier at the end of the day”.<br />
else<br />
If”a person doesn’t speñd the money on himself”,<br />
then<br />
“he will be happier at the end of the day”.</p>
<p>Example &#8211; III:<br />
If son said “I do my homework”<br />
then<br />
Father represent &#8220;I get my payment&#8221;<br />
The statement son → father is a conditional statement which represent &#8220;if son, then father&#8221;.</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p><span style="color: #0000ff;">Choose the correct answer:</span></p>
<p>Question 1.<br />
Which statement is a combination of if-else statement?<br />
(a) If statement<br />
(b) break statement<br />
(c) If&#8230;elseif&#8230;else statement<br />
(d) If&#8230;else statement<br />
Answer:<br />
(c) If&#8230;elseif&#8230;else statement</p>
<p>Question 2.<br />
Which statement is used to perform different actions based on different conditions?<br />
(a) If statement<br />
(b) Switch statement<br />
(c)If&#8230;elseif&#8230;else statement<br />
(d) If.. .elsestatement<br />
Answer:<br />
(b) Switch statement</p>
<p>Question 3.<br />
Which statement contains boolean expression inside brackets?<br />
(a) if statement<br />
(b) switch statement<br />
(c) break statement<br />
(d) default statement<br />
Answer:<br />
(a) if statement</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 4.<br />
Which statement executes a statement if a specific condition is satisfied?<br />
(a) if statement<br />
(b) switch statement<br />
(c) break statement<br />
(d) default statement<br />
Answer:<br />
(a) if statement</p>
<p>Question 5.<br />
What type of statements are useful for writing decision making logics?<br />
(a) looping<br />
(b) conditional<br />
(c) branch statement<br />
(d) All the above<br />
Answer:<br />
(b) conditional</p>
<p>Question 6.<br />
What will be the output in the PHP code?<br />
&lt;?php<br />
$x = 0; &#8216;<br />
if ($x = = 1) ’<br />
if ($x &gt; = O&#8217;) &#8216;<br />
print &#8220;true&#8221;; .<br />
else<br />
print &#8220;false&#8221;;<br />
?&gt;<br />
(a) true<br />
(b) false<br />
(c) error<br />
(d) no output<br />
Answer:<br />
(d) no output</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 7.<br />
What will be the output in the PHP code?<br />
&lt;? php<br />
$a = 1&#8242;; .<br />
if ($a—) print &#8220;True&#8221;;<br />
if ($a++)<br />
print &#8220;False&#8221;; .<br />
?&gt;<br />
(a) true<br />
(b) false<br />
(c) error<br />
(d) no output<br />
Answer:<br />
(a) true</p>
<p>Question 8.<br />
What will be the output in the PHP code?<br />
&lt;? php<br />
$a « 1;<br />
If (print $a)<br />
print &#8220;true&#8221;;<br />
else<br />
print &#8220;false&#8221;;<br />
?&gt;<br />
(a) true<br />
(b) false<br />
(c) error<br />
(d) no output<br />
Answer:<br />
(a) true</p>
<p>Question 9.<br />
What will be the output in the PHP code?<br />
&lt;? php<br />
$a = &#8221;<br />
if ($a) .<br />
print &#8220;all&#8221;;<br />
if<br />
else<br />
print &#8220;some&#8221;;<br />
?&gt;<br />
(a) all<br />
(b) some<br />
(c) error<br />
(d) no output<br />
Answer:<br />
(b) some</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 10.<br />
The following syntax is correct for if conditional statement.<br />
if condition<br />
{<br />
code<br />
}<br />
(a) true<br />
(b) false<br />
(c) error<br />
(d) not correct<br />
Answer:<br />
(a) true</p>
<p>Question 11.<br />
If &lt;expression&gt; Where, the expression can be of which type?<br />
(a) True<br />
(b) Any number<br />
(c) Any string<br />
(d) All the above<br />
Answer:<br />
(d) All the above</p>
<p>Question 12.<br />
What error does the if condition gives if not terminated with end statement?<br />
(a) Syntax error<br />
(b) Unexpected end<br />
(c) Expecting keyword end<br />
(d) All the above<br />
Answer:<br />
(d) All the above</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 13.<br />
What is output?<br />
if 1 &lt; 2<br />
Print &#8220;One is less than Two&#8221;;<br />
end<br />
(a) error<br />
(b) syntax error<br />
(c) one is less than two<br />
(d) none<br />
Answer:<br />
(c) one is less than two</p>
<p>Question 14.<br />
What is output?<br />
if 11 &lt; 2<br />
Print &#8220;Eleven is less than two&#8221;<br />
end<br />
print &#8220;11 is greater&#8221;<br />
(a) 11 is greater<br />
(b) Eleven is less than two<br />
(c) Eleven is less than two 11 is greater<br />
(d) None<br />
Answer:<br />
(a) 11 is greater</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 15.<br />
What is output?<br />
&lt;? php<br />
$x = 12; .<br />
if ($x &gt;0)<br />
{<br />
echo &#8220;positive number&#8221;<br />
}<br />
else<br />
{<br />
echo &#8220;Negative number&#8221;<br />
}<br />
?&gt;<br />
(a) positive<br />
(b) negative<br />
(c) error<br />
(d) no output<br />
Answer:<br />
(a) positive</p>
<p>Question 16.<br />
Match the following:</p>
<table border="2">
<tbody>
<tr>
<td width="150">(A) If</td>
<td width="258"> (i) group of statement</td>
</tr>
<tr>
<td width="150">(B) If &#8211; else</td>
<td width="258"> (ii) a statement</td>
</tr>
<tr>
<td width="150">(C) If &#8211; elseif &#8211; else</td>
<td width="258"> (iii) multiple values</td>
</tr>
<tr>
<td width="150">(D) Switch</td>
<td width="258"> (iv) combination of if &#8211; else statement</td>
</tr>
</tbody>
</table>
<p>(a) (A) &#8211; (ii); (B) &#8211; (iii); (C) &#8211; (i); (D) &#8211; (iv)<br />
(b) (A) &#8211; (ii); (B) &#8211; (i); (C) &#8211; (iv); (D) &#8211; (iii)<br />
(c) (A) &#8211; (iv); (B) &#8211; (iii); (C) &#8211; (i); (D) &#8211; (ii)<br />
(d) (A) &#8211; (iv); (B) &#8211; (i); (C) &#8211; (ii); (D) &#8211; (iii)<br />
Answer:<br />
(b) (A) &#8211; (ii); (B) &#8211; (i); (C) &#8211; (iv); (D) &#8211; (iii)</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 17.<br />
Choose the incorrect pair:<br />
(a) condition &#8211; decision<br />
(b) if &#8211; control statement<br />
(c) switch &#8211; multiple statement<br />
(d) else if &#8211; another condition<br />
Answer:<br />
(b) if &#8211; control statement</p>
<p>Question 18.<br />
Choose the incorrect statement:<br />
(a) Switch statement work with same as while statements.<br />
(b) The if statement is way to make decision based statement.<br />
(c) If statement contains boolean expression inside brackets.<br />
(d) The else statement must follow if or else if statement.<br />
Answer:<br />
(a) Switch statement work with same as while statements.</p>
<p>Question 19.<br />
Assertion (A):<br />
Conditional statements are useful for writing decision making logics.<br />
Reason (R):<br />
It is most important feature of many programming languages, including PHP<br />
(a) Both A and R are true, and R is the correct explanation for A.<br />
(b) Both A and R are true, but R is not the correct explanation for A.<br />
(c A is true, But R is false.<br />
(d) A is false, But R is true.<br />
Answer:<br />
(a) Both A and R are true, and R is the correct explanation for A.</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 20.<br />
Pick the odd one out:<br />
(a) If<br />
(b) If&#8230;else<br />
(c) break<br />
(d) Switch<br />
Answer:<br />
(c) break</p>
<p>Question 21.<br />
What will be the output of the following PHP code?<br />
&lt;?php<br />
$x;<br />
if ($x)<br />
print &#8220;hi&#8221; ;<br />
else<br />
print &#8220;how are u&#8221;;<br />
?&gt;<br />
(a) how are u<br />
(b) hi<br />
(c) error<br />
(d) no output<br />
Answer:<br />
(a) how are u</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 22.<br />
What will be the output of the following PHP code ?<br />
&lt;?php<br />
$x = 0;<br />
if ($x++)<br />
print &#8220;hi&#8221;; .<br />
else<br />
print &#8220;how are u&#8221;;<br />
?&gt;<br />
(a) hi<br />
(b) no output<br />
(c) error<br />
(d) how are u<br />
Answer:<br />
(d) how are u</p>
<p>Question 23.<br />
What will be the output of the following PHP code?<br />
&lt;?php<br />
$x;<br />
if ($x == 0)<br />
print &#8220;hi&#8221; ;<br />
else<br />
print &#8220;how are u&#8221;;<br />
print &#8220;hello&#8221;<br />
?&gt;<br />
(a) how are uhello<br />
(b) hihello<br />
(c) hi<br />
(d) no output<br />
Answer:<br />
(b) hihello</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 24.<br />
Statement which is used to make choice between two options and only option is to be performed is written as:<br />
(a) if statement<br />
(b) if else statement<br />
(c) then else statement<br />
(d) else one statement<br />
Answer:<br />
(b) if else statement</p>
<p>Question 25.<br />
What will be the output of the following PHP code ?<br />
&lt;?php<br />
$a = &#8220;&#8221;;<br />
if ($a)<br />
print &#8220;all&#8221;;<br />
if<br />
else<br />
print &#8220;some&#8221;;<br />
?&gt;<br />
(a) all<br />
(b) some<br />
(c) error<br />
(d) no output<br />
Answer:<br />
(b) some</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 26.<br />
What will be the output of the following PHP code?<br />
&lt; ?php<br />
$a = &#8220;&#8221; ;<br />
if ($a)<br />
print &#8220;all&#8221;;<br />
if<br />
else<br />
print &#8220;some&#8221;;<br />
?&gt;<br />
(a) all<br />
(b) some<br />
(c) error<br />
(d) no output<br />
Answer:<br />
(b) some</p>
<p>Question 27.<br />
What will be the output of the following PHP code?<br />
&lt;?php<br />
$x = 10;<br />
$y = 20;<br />
if ($x &gt; $y + $y != 3)<br />
print &#8220;hi&#8221; ;<br />
else<br />
print &#8220;how are u&#8221;;<br />
?&gt;<br />
(a) how are u<br />
(b) hi<br />
(c) error<br />
(d) no output<br />
Answer:<br />
(b) hi</p>
<p>Question 28.<br />
What will be the output of the following PHP code?<br />
&lt;?php<br />
$x = 10;<br />
$y = 20;<br />
if ($x &gt; $y &amp;&amp; 1||1)<br />
print &#8220;hi&#8221; ;<br />
else<br />
print &#8220;how are u&#8221;;<br />
?&gt;<br />
(a) how are u<br />
(b) hi<br />
(c) error<br />
(d) no output<br />
Answer:<br />
(b) hi</p>
<p><img decoding="async" src="https://samacheer-kalvi.com/wp-content/uploads/2021/08/Samacheer-Kalvi.png" alt="Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 6 PHP Conditional Statements" width="147" height="12" /></p>
<p>Question 29.<br />
What will be the output of the following PHP code ?<br />
&lt;?php<br />
if .(-100)<br />
print &#8220;hi&#8221; ;<br />
else<br />
print &#8220;how are u&#8221;;<br />
?&gt;<br />
(a) how are u<br />
(b) hi<br />
(c) error<br />
(d) no output<br />
Answer:<br />
(b) hi</p>
<h4><a href="https://samacheer-kalvi.com/tn-board-12th-computer-applications-important-questions/">TN Board 12th Computer Applications Important Questions</a></h4>
]]></content:encoded>
					
					<wfw:commentRss>https://samacheer-kalvi.com/tn-board-12th-computer-applications-important-questions-chapter-6/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">46185</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 

Served from: samacheer-kalvi.com @ 2026-06-27 12:50:57 by W3 Total Cache
-->