Selection Structure
Selection Structure
Selection Structure allot the computer to work decisions in your programs. It selects a evidence or set of statements to punish on the portion of a stipulation.
Types: ·
If-else artefact ·
Switch structure
If-else structure:
The if-else statement is an extension of the retarded if evidence. It executes one statement if it is unfeigned and opposite one if procedure is pretended.
Switch structure
It is victimized when there are many choices and only one statement is to be executed.
If Statement
The simplest if artifact involves a individual workable evidence. Enforcement of the evidence occurs exclusive if the procedure is harmonious.
Structure:
if (term)
statement;
Travel chart
Example:
#include<stdio.h>
#include<conio.h>
void main ()
{
int marks;
clrscr();
{
printf("Enter your marks:");
scanf("%d",&marks);
if(marks >=50)
printf("CONGRATULATIONS...!!! you have passed.");
}
getch();
}
Disadvantages
The evidence(s) are executed if the status is harmonious; if the term is inharmonious zilch happens in additional text we may say it is not the competent one. Instead of it we use if-else statements etc.
Selection Structure allot the computer to work decisions in your programs. It selects a evidence or set of statements to punish on the portion of a stipulation.
Types: ·
If-else artefact ·
Switch structure
If-else structure:
The if-else statement is an extension of the retarded if evidence. It executes one statement if it is unfeigned and opposite one if procedure is pretended.
Switch structure
It is victimized when there are many choices and only one statement is to be executed.
If Statement
The simplest if artifact involves a individual workable evidence. Enforcement of the evidence occurs exclusive if the procedure is harmonious.
Structure:
if (term)
statement;
Travel chart
Example:
#include<stdio.h>
#include<conio.h>
void main ()
{
int marks;
clrscr();
{
printf("Enter your marks:");
scanf("%d",&marks);
if(marks >=50)
printf("CONGRATULATIONS...!!! you have passed.");
}
getch();
}
Disadvantages
The evidence(s) are executed if the status is harmonious; if the term is inharmonious zilch happens in additional text we may say it is not the competent one. Instead of it we use if-else statements etc.