Decision
making structures allows the programmer to specify one or more conditions to be
evaluated or tested by the compiler or , along with a statement or set of
statements to be executed if the condition is
true, and other statements to be
executed if the condition is false.
Most of the programming languages follows the
same decision making structure:
In C programming language any non-zero and non-null values is true, and if it is either zero or null, then
it is assumed as false value.
C
programming language has following types
of decision making statements.
Statement Description
1.if
statement It consists of a boolean condition
followed by one or more statements.
2.if...else
statement It can be
followed by an optional else statement, which executes when the condition is
false.
3.nested
if statements if or else if
statement inside another if or else if statement(s).
4.switch
statement It allows a variable to be tested for
equality against a list of values.
5.nested
switch statements You can use one switch
statement inside another switch statement(s).
6.The
? : Operator:
Example
of conditional operator
Exp1
? Exp2 : Exp3;
Where
Exp1, Exp2, and Exp3 are expressions.
The
value of a ? expression is determined like this:first Exp1 is evaluated. If Exp1 is true, then Exp2
is evaluated otherwise then Exp3 is evaluated and its value becomes the value
of the expression.
|
|||||
C - Overview | |||||
C - Basic Syntax | |||||
C - Data Types | |||||
C - Variables | |||||
C - Constants | |||||
C - Storage Classes | |||||
C - Operators | |||||
C - Decision Making | |||||
C - Loops | |||||
C - Functions | |||||
C - Scope Rules | |||||
C - Arrays | |||||
C - Pointers | |||||
C - Strings | |||||
C - Structures | |||||
C - Unions | |||||
C - Bit Fields | |||||
C - Typedef | |||||
C - Input & Output | |||||
C - File I/O | |||||
C - Preprocessors | |||||
C - Header Files | |||||
C - Type Casting | |||||
C - Error Handling | |||||
C - Recursion | |||||
C - Variable Arguments | |||||
C - Memory Management | |||||
C - Command Line Arguments |
Sunday, 24 November 2013
Home »
C language
» Decision Making Structure In C
0 comments:
Post a Comment