0% found this document useful (0 votes)
9 views6 pages

Conditional Statements

The document explains control structures in programming, which dictate the flow of a program. It details three types of control structures: conditional statements, looping statements, and jumping statements, with a focus on conditional statements including simple if, if...else, and nested if. Examples in C demonstrate how to implement these conditional statements to evaluate conditions and execute corresponding blocks of code.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views6 pages

Conditional Statements

The document explains control structures in programming, which dictate the flow of a program. It details three types of control structures: conditional statements, looping statements, and jumping statements, with a focus on conditional statements including simple if, if...else, and nested if. Examples in C demonstrate how to implement these conditional statements to evaluate conditions and execute corresponding blocks of code.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Control structures:

We control the sequence of the structure of a program is called control structures.

There are three types of control structures

1. Conditional statements:
2. Looping statements
3. Jumping statements
1. Conditional statements: the decision is making based on condition and execute the statements
a. Simple if
b. If…else
c. If….else…if
d. Nested if
e. Switch

a. Simple if: it checks the condition first, if the condition is true then execute block of
statements , otherwise stop the program with out any execution.

Syntax: if(condition)

Statements

false true

conddd

Block of statements

end
#include<stdio.h>

#include<conio.h>

void main()

int num;

clrscr();

printf("enter a number");

scanf("%d",&num);

if(num%2==0)

printf("the given number is even");

getch();

Example :2

#include<stdio.h>

#include<conio.h>

void main()

int age;

clrscr();

printf("enter your age");

scanf("%d",&age);

if(age>18)

{
printf("eligible for vote");

getch();

}
b. If….else: it checks the condition first, if the condition is true then execute block of
statements , otherwise it executes the else block statements

Syntax: if(condition)

Statements

else

statements

false true
conddd

Else Block of
Block of statements
statements

end

#include<stdio.h>

#include<conio.h>

void main()

int num;
clrscr();

printf("enter a number");

scanf("%d",&num);

if(num%2==0)

printf("the given number is even");

else

printf("the given number is odd");

getch();

Example :2

#include<stdio.h>

#include<conio.h>

void main()

int age;

clrscr();

printf("enter your age");

scanf("%d",&age);

if(age>18)

{
printf("eligible for vote");

else

printf("not eligible for vote");

getch();

You might also like