Decission making

decissional programming

In this kind of programming we implement different decissions making statements in order to confirm whether a task is to be done or not. following are the decission making statement supported by C

decissional programming-:
->if - statement
->if-else statement
->switch case statement
-:The conditional operator
The if statement -:

The if statement puts a condition which is always in the form of realation and after the judgement of that condition either true or false c compiler is redirected to another group of instructions.
syntax-:
void main
{
______
______
______
if (condition)
{
_______
_______
_______
}
________
________
________
getch();
}
#include
#include
void main()
{
int a,b;
clrscr();
printf("Enter two values");
scanf("%d%d",&a&b);
if(a>b)
{
printf("hi this is abc");
printf("the first value is greater");
}
printf("program ended");
printf("thanks for watching");
getch();
}


#include
#include
void main()
{
int a;
clrscr();
printf("Enter age of person");
scanf("%d",&a);
if(a>60)
{
printf("senior citizen");
}
printf("program ended");
printf("thanks for watching");
getch();
}


#include
#include
void main()
{

char ch1;
clrscr();
printf("Enter the character");
scanf("%c",&ch1);
if(ch1>=65&&ch1<=90)
{
printf("the character is in capital letter");
}
printf("program ended");
printf("thanks for watching");
getch();
}


#include
#include
void main()
{
char ch1;
clrscr();
printf("Enter your gender m for male f for female");
scanf("%c",&ch1);
if(gender=='m')
{
printf("THE USER IS MALE");
}
printf("program ended");
printf("thanks for watching");
getch();
}


the if else statement-:


when we have to handle both true and false conditions we have to use the if els statement.here,if handles the true case while else handles the false case.

syntax-:
____________
____________
____________
____________
if (condition)
{
____________
____________
____________
}
else
{
____________
____________
____________
}
____________
____________
____________

#include
#include
void main()
{
int num1,num2;
clrscr();
printf("Enter two values");
scanf("%d%d",&num1&num2);
if(num1>num2)
{
printf("the first value is greater");
}
else
{
printf("second is greater");
}
printf("thanks for watching");
getch();
}




#include
#include
void main()
{
int num1;
clrscr();
printf("Enter value to check it is even or odd");
scanf("%d",&num1);
if(num1%2==0)
{
printf("number is even");
}
else
{
printf("number is odd");
}
printf("thanks for watching");
getch();
}
program to check that the number is pallindrome or not (only for three digit number)




#include
#include
void main()
{
int num;
clrscr();
printf("Enter value to check it is pallindrome or not");
scanf("%d",&num);
x=num;
a=num%10;
num=num/10;
b=num%10;
num=num/10;
n=(a*100)+(b*10)+(num*1);
if(num==x)
{
printf("number is pallindrome");
}
else
{
printf("number is not pallindrome");
}
printf("thanks for watching");
getch();
}



#include
#include
void main()
{
int m1,m2,m3,m4,m5,t,p;
clrscr();
printf("Enter the marks of 5 students ");
scanf("%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5);
t=m1+m2+m3+m4+m5;
p=(t/500)*100;
if(p>=50)
{
printf("the student is pass");
}
else
{
printf("THE STUDENT IS FAIL");
}
printf("thanks for watching");
getch();
}




#include
#include
void main()
{
long int ta,da,hra,basic;
printf("enter the basic salary of employee");
scanf("%ld",&basic);
if (basic<=50000)
{
da=(15*basic)/100;
ta=(12*basic)/100;
hra=(12*basic)/100;
gs=ta+da+hra+basic;
printf("the gross salary is%ld",gs");
}
else
{
da=10000;
ta=8000;
hra=(18*basic)/100;
gs=ta+da+hra+basic;
printf("the gross salary is%ld",gs);
}
getch();
}