2 - Second Chapter Decision Making Statement
2 - Second Chapter Decision Making Statement
Explanation:-
In simple if statement if condition is true then execute the if block if
condition
False then execute the other programme part.
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
else{
false statement block
}
else
{
statement block
}
other programme part
#include<stdio.h>
#include<conio.h>
void main(){
int id,sal;
clrscr();
printf(“enter the id of employee \n”);
scanf(“%d”,&id);
if(id==1||id==2)
{
printf(“enter the salary of employee \n”);
scanf(“%d”,&sal);
if(sal>5000)
{
printf(“employee is permanent”);
}
else
{
printf(“employee is temporary \n”);
}
else
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
{
printf(“employee is not a member of organization”);
}
getch();
}
Output:
#include<stdio.h>
#include<conio.h>
void main(){
int a,b,c;
clrscr();
printf(“enter the three number “);
scanf(“%d%d%d”,&a,&b,&c);
if(a>b&&a>c)
{
printf(“a is the greater %d”,a);
}
else if(b>a&&b>c)
{
printf(“b is the greater %d”,b);
}
else{
printf(“c is the greater %d”,c);
}
getch();
}
Output:
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
case 2:
statement
break;
case 3:
statement
break;
default:
Statement
}
In switch if case match with given choice then the particular case block
Will execute.
#include<stdio.h>
#include<conio.h>
void main(){
int choice;
clrscr();
printf(“enter the your choice”);
scanf(“%d”,&choice);
switch(choice)
{
case 1:
printf(“your choice is %d”,choice);
break;
case 2:
printf(“your choice is %d”,choice);
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
break;
case 3:
printf(“your choice is %d”,choice);
break;
default:
printf(“your choice is wrong”);
}
getch();
}
else
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
bill=235+400*5.65+500*7.25+(units-1000)*9.85;
printf(“\n the bill is %2f”,bill);
getch();
}
Output:
}
Output:-
#include<stdio.h>
#include<conio.h>
void main(){
int num;
clrscr();
printf(“\n enter the number “);
scanf(“%d”,&num);
if(num>0)
printf(“\n the number is positive”);
if(num<0)
printf(“\n the number is negative”);
if(num==0)
printf(“\n the number is zero”);
getch();
}
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)
GIRI’S TECH HUB,Pune(IT Training Institute With 100% Guaranteed Placement Support Mob:9175444433)