Decision  statements concepts explanation :

Decision statements are classifeied into 

simple "If" :

*if statement is powerfull decision making statement 

* It is used to control the flow of excution of statement 

syntax

if(condition)// dont mention any commas /semicolons

{

printf("star code learns");

}


NOTE: 

  • It is a basically two way decision statement , one true and another one is false 
  • It have only one option . our condition either true or false 
The statement has excuted only when the condition is true,In case the condition is false , the compiler skip the line with in the if block 

program :

#include<stdio.h>

#include<conio.h>

main()

{

int A,b;

printf(" enter the values of A & B");

scanf("%d%d",&A&B);

if (A-B)==0)

{

printf("A-B values are equal to zero ");

}

printf("it is false statement");

}

*If else statement :

  1. it is observe that if statement excuted only when the condition is true it is excuting the if condition
  2. in if-else either true block or false blolck will be excuted and not both . the else statement cannot be used " without if
syntax :

if else

#include<stdio.h>

main()

{

printf(" condition true");

}

else

{

printf(" condition false");

}

program:

#include<stdio.h>

main()

int a;

printf("enter the value of number");

scanf("%d",&a);

if ((a%2)==0)

{

printf("the given even value");

}

else

{

printf("the given value odd");

}

printf ("thank you");

}

*nested if:

using of one if else statement in another if else statement is called nested if else 

when a serial of decision is involved we may have use more than one if else statement in nested form

program

#include<stdio.h>

main()

{

int a,b,c

printf(" enter the value of a,b,c");

scanf("%d%d%d",&a,&b,&c);

printf("the biggest number is ");

if(a>b)

{

if(a>c)

{

printf("%d",%a);

}

else

{

printf("%d",c);

}

else

{

if(b>c)

{

printf("d",b);

}

}

if else ladder:

  • switch case: a witch case is another condition or control statement used to select one optoin from several option based on given expresion value , there ius no alternative for"if else ladder"
  • switch statement causes a particular group of statement to be hoosen from several available group
  • the selection is based upon  current value of an expression . ehich include with in the switch statement 
  • a switch statement is multiple(or) multiway branch statement 
a switch statement required only one argument of int or char data type . which is check with in no.of case option . every case statements excuted if the condition is satisfy otherwise the case statement is terminate,in switch each case block should end  with break statemen 

program:

#include<stdio.h>

#include<conio.h>

main()

{

int a, b, scl;

printf("enter the values of ab");

scanf("%d%d",&a&b);

}

switch(scl)

{

case: scl=a+b

printf("sum of a+b=%d",a+b);

break;

// like same in subtaction and multiplication and divison ,try it yourself and answer in comment box//