Thursday, August 27, 2020

9.3 Introduction to C Decision Making

  • You can decide which statements you want to execute in your program and which statements you want to skip. 
  • This is called decision making. 
  • Most decisions are done on a condition basis. 
  • When a particular condition arrives, you can execute the statements you want. 
  • For this, you use some built in statements. 
  • Because these statements work with the conditions, they are also called conditional statements. 
  • And because they control execution in the statement program, they are also called control statements. 
  • Suppose you want to print the name of any of the two students whose age is over.
  • How can you do this? See the program below.

#include <stdio.h>
int main()
{
sudoAge = 22;
bkAge = 21;
}

  • In the above example, 2 students have been stored in age 2 variables. 
  • But you only have to print the age of the student whose age is the highest. 
  • In this situation you need to take a decision. 
  • You can do this by any decision making statement (If, If-else, Switch).





No comments:

Post a Comment

Please do not any spam link in Comment Box