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
Decision Making Structure In C
Related Posts:
Algorithm and program for Binary Search. Binary search or half-interval search algorithm compares the element to be search(i.e key) with the middle element of the array. If the key is matched with the middle element ,it returns its positi… Read More
Difference between printf("%d") and printf("%d",x) 1. When we write printf("%d",x); the compiler will print the value of x. But where there is nothing after %d so compiler will show garbage value. 2. When we use %d the compiler internally uses it to access the a… Read More
Difference between Declaring a variable , Defining a variable ,Internal static variable and External static variable Declaring a variable Declaring a variable means describing its type (data type) but not allocating any space for it. Defining a variable: Defining a variable means declaring it and also allocating space to hold… Read More
Types of Pointer in C Pointer is of five types:: 1.Wild pointer: A pointer which has not been initialized is known as wild pointer. int *ptr; printf("%d",*ptr); //Output: Garbage Value 2.Dangling pointer: If any pointer is pointin… Read More
Difference between Malloc and Calloc 1. calloc(...) allocates a block of memory for an array of elements of a certain size. By default the block is initialized to Zero. The total number of memory allocated will be (number_of_elements * &… Read More
0 comments:
Post a Comment