0% found this document useful (0 votes)
11 views12 pages

Conditional Statements

The document outlines various conditional statements in programming, including if statements, if-else statements, nested if-else statements, and switch statements. It explains the syntax and functionality of each type, highlighting how they control the flow of execution based on conditions. Additionally, it briefly mentions the use of strings for text storage and the C# Math class for mathematical operations.

Uploaded by

tanisha4803.tp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views12 pages

Conditional Statements

The document outlines various conditional statements in programming, including if statements, if-else statements, nested if-else statements, and switch statements. It explains the syntax and functionality of each type, highlighting how they control the flow of execution based on conditions. Additionally, it briefly mentions the use of strings for text storage and the C# Math class for mathematical operations.

Uploaded by

tanisha4803.tp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Conditional statements

1. If statement
2. If – else statement
3. Nested if statement
4. Switch case statement
If statement
• If statement is the simplest conditional statement.
• If enables us to check conditional is true or false.
• When the condition is true it will execute the statement
and when false it will not execute the statement.
• If syntax :
If (condition if true)
{
execute the statement
}
If else statement
• More complex and useful condition statement.
• Execute the one branch if the condition is true , and another if it is
false.
• The simplest form of the if else statement:
• If (expression)
{
statement 1;
}
Else
{
statement 2;
}
• The condition evaluated
if it is true ,the first statement is executed
 if it is false, the second statement is executed
Nested if else
• Nested if else Statement in C# – Nested if else statement in C# means, if else
statement inside another if else statement.
• Syntax:
if (expression)
{
if (expression)
{
statement;
}
else
{
statement;
}
} else
statement;
Switch statement
• The switch statement is used when we have
multiple condition but only one condition true
and only that code will be executed.
In other word we can say execute one of
multiple blocks of code to be executed.
• The switch statement works same as if-else if-
else statement.
• switch (a)
{
case statement1:
if a=statement1 then code to be executed;
break;
case statement2:
if a=statement2 then code to be executed;
break;
case statement3:
if a=statement3 then code to be executed;
break;
…….
default:
if “a” is not matches with any statement then code to be executed.
}
String

• Strings are used for storing text.


• A string variable contains a collection of
characters surrounded by double quotes
Math
• The C# Math class has many methods that
allows you to perform mathematical tasks on
numbers.

You might also like