Posts

Showing posts from September, 2012

goto statement

Image
The Goto statement :- C language supports " goto " statement to branch unconditionally from one point to another in the program. The goto requires a label in order to identify the place where the branch is to be made. A label is any valid variable name, and must be followed by a colon. The label is placed just before the statement where the control is to be transferred.   The general forms of goto and label statements are:- The " label: " can be anywhere in the program either before or after the " goto label; " statement. While executing the program,when a statement like "goto begin;" is met, the flow of control will jump to the statement immediately following the label "begin:". A goto breaks the normal sequencial execution of the program. If the "label:" is before the statement "goto label;"   a loop will be formed and some statments will be executed repeatedly. Such a jump is calle

Looping

Image
Looping :- Looping is a condition, in which a sequence of statements are executed until some conditions for termination of the loop are satisfied. A program loop consists of two part, one known as body of the loop and the other is known as control statement.  The control statement checks the specified condition and then performs the repeated execution of the statements contained in the body of the loop . i.e. control statement is a looping's part  that tests wheter the given condition is satisfying or not, if it is satisfiying then it directs the flow control to the body of the loop to b executed, until the specified condition do not gets false. Body of the loop is the part of looping which contains the packet of command line, which gets executed when the given condition in control statements satisfies. A looping process include following four steps :-   i) Setting and initialization of a condition variable.   ii) Execution of the statements in the loop.   iii) Test for

Conditional Operator

The Conditional (? :) operator :- Conditional operator is   a combination of "?" and ":" and takes three operands. It is useful for making two-way decisions. General form of this operator is :-   "conditional expression ? expression 1 : expression 2" While executing this operator, conditional expression is evaluated first, if the result is non-zero, expression 1 is evaluated and is returned as the value of the conditional expression. Otherwise, expression 2 is evaluated and its value is returned as the value of conditional expression. For example, consider an if else expression :- if (x < 0)     flag = 0; else      flag = 1; But using conditional operator, it can be written as :-                                                                 flag = (x < 0) ? 0 : 1; Here if the value of x is smaller then 0, than the value of flag will be 0, and if the value of x is greater then 0, than value of flag will be 1. When the