Computer Science, asked by shimpythe568, 20 days ago

Explain the different types of control statements with example?​

Answers

Answered by ansarifatma61
1

EDUCBAEDUCBA

Menu

Control Statements in C

By Swati TawdeSwati Tawde

Home » Software Development » Software Development Tutorials » C Programming Tutorial » Control Statements in C

Control Statement in C

Introduction to Control Statements in C

In C, the control flows from one instruction to the next instruction until now in all programs. This control flow from one command to the next is called sequential control flow. Nonetheless, in most C programs the programmer may want to skip instructions or repeat a set of instructions repeatedly when writing logic. This can be referred to as sequential control flow. The declarations in C let programmers make such decisions which are called decision-making or control declarations. Below we will discuss the types of Control Statements in C.

Types of Control Statements in C

C also supports an unconditional set of branching statements that transfer the control to another location in the program. Selection declarations in C.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

If statements

Switch Statement

Conditional Operator Statement

Goto Statement

Loop Statements

1. If Statements

If statement enables the programmer to choose a set of instructions, based on a condition. When the condition is evaluated to true, a set of instructions will be executed and a different set of instructions will be executed when the condition is evaluated to false. We have 4 types of if Statement which are:

1. If..else

2. Nested if

3. Else if ladder

4. Simple if or null else

5. Null else or Simple else

2. Switch Statement

C offers a selection statement in several ways as if the program becomes less readable when the number of conditions increases. C has a multi-way selection statement called the switch statement that is easy to understand to resolve this problem. The switch declaration is easy to understand if more than 3 alternatives exist. The command switches between the blocks based on the expression value. Each block will have a corresponding value

.3. Conditional Operator Statement

C language provides an unusual operator, which is represented as a conditional operator

.4. goto Statement

goto statement is known for jumping control statements. It is used to transfer the control of the program from one block to another block. goto keyword is used to declare the goto statement.

5. Loop Statements

The programmer may want to repeat several instructions when writing C programs until some requirements are met. To that end, C makes looping declarations for decision-making. We have three types of loops,

For Loop

While Loop

Do While Loop

please mark me as a brainliest answer

Similar questions