Decision making in C programming have structures. These decision making structures require programmers to specify either one or more than one statements. In last chapter, you studied C operators. However, this chapter is about C decision making statements. You will also learn C decision making statements.
Decision making C lesson
Furthermore, programmers specify conditions. Because program will test these conditions. In addition, program will test statement, which it will execute. It happens only when condition is true. In addition, it may continue process when condition is false.
Points to remember
- C program language will assume that non zero as well as non null values are true
- In case it is zero or null then it will take as false value
You can continue reading to know decision making statements type. You will also know use of decision making C programming language use.
Lists of decision making statements with description in C
Name of the statement | Description |
if…else statement | Optional else statement may follow this statement. Because this will execute only when Boolean expression is false |
if statement | However, if statement has Boolean expression. After this there can be either one or more than one statements |
switch statement | But switch statement will allow variable to test. This test is to check equality against list of values |
nested if statements | C programming language allows you to use either one if or else if statement. In addition, you may use it in another if or else if statement or statements |
nested switch statements | Finally, you may use one switch statement in another switch statement or statements |
? : operator in C programming language decision making
You must remember that conditional operator ? : replaces if…else statements.
General form of conditional operator ? : is
Exp1 ? Exp2 : Exp3; |
In the above general form, expressions are Exp1 and Exp2. Even Exp3 is an expression. Moreover, you can check how we used expressions. Furthermore, colon is also applicable.
How to define value of ? expression
For this, you should follow the rules. When you evaluate Exp1. Moreover, if it turns true. In such cases, Exp2 evaluates. In addition, this will be value of entire ? expression.
However, in cases where Exp1 is false. Then you must evaluate Exp3. As a result value of Exp3 is value of complete expression.
Thus, you learnt C programming decision making and branching. In addition, you also got to know C programming decision making examples. So, practice C decision making programs in C language examples. Because this will help you in C loops chapter.
No comments:
Post a Comment