CONTROL STATEMENT IN C

Maha

Control Statement In C

  • Control statement in C programming language are used to control the flow of execution of a program.
  • These control statements are very important in programming as they allow the programmer to create a complex programs with more control over the flow of execution.

 There are three types of control statements in C:

               1. Conditional statement
               2. Looping statement
               3. Jump statemen

 Conditional Statement:

  • Conditional statements allow the program to be execute the different block of code depending on whether a condition is true or false.
  • The most common conditional statement is the "if-else" statement

Syntax:

if (condition) 

// code to be executed if the condition is true
}

Types Of Conditional Statement:

     • if statement
     • if-else statement
     • nested if statement
     • switch statement

Looping Statement: 

Looping statements allow a block of code to be execute repeatedly until a certain condition is met. This is known as looping statements in C.

Syntax:

while (condition);
for (initialization; condition; increment)
{
  // code to execute repeatedly while condition is true
}

Types Of  Looping Statements:

• while loo
• do-while loop
• for loop

Jump Statement:

 Jump statements allow the program to transfers control to a different part of the program. It is a jump statements in C.

Syntax:

break; // -used to exit a loop
continue; // -used to skip to the next  of a loop
goto label; // -used to transfer control  statement in the program

Types Of Jump Statement:

• break statement
• continue statement
• goto statement
• return statement


Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send