Theory
Theory
**1)if (condition)
**2)
if (condition)
else
For example=>
switch (expression) {
case value1:
// Code to be executed if expression == value1
break;
case value2:
// Code to be executed if expression == value2
break;
...
default:
// Code to be executed if none of the cases match
break;
}
Syntax=>
for (initialization; condition; update) {
// code to be executed
}
while loop=>
A while loop in C is a control low structure that allows for a piece of code
to be executed repeatedly as long as a particular condition is true.
Syntax:
while (condition) {
// code to be executed
}
do-while loop=>
The do-while loop checks the condition after executing the loop body,
which ensures that the loop body is executed at least once, even if the
condition is initially false.
Syntax:
do {
// code block
} while (condition);
Jump statement:
Jump Statement in C is used in C programming language to
transfer control from one part of the program to another.
There are four types of Jump Statements in C: break,
continue,return and goto. While these statements can be useful in
certain situations, they can also lead to errors if not used properly.
Nested loop=>
A nested loop is a loop inside another loop. The most common nested loop
is a for loop.
For example =>
// outer loop
// codes
// inner loop
// codes
Ladder conditions=>
if else if ladder in C programming is used to test a series of conditions sequentially.
For example =>
void main() {
int number;
if (number > 0) {
printf("The number is positive.\n");
}
getch();
}