answersLogoWhite

0

C provides two sytles of flow control:

  • Branching
  • Looping

Branching is deciding what actions to take and looping is deciding how many times to take a certain action. Branching: Branching is so called because the program chooses to follow one branch or another.

if statementThis is the most simple form of the branching statements.

It takes an expression in parenthesis and an statement or block of statements. if the expression is true then the statement or block of statements gets executed otherwise these statements are skipped.

? : OperatorThe ? : operator is just like an if ... else statement except that because it is an operator you can use it within expressions.

? : is a ternary operator in that it takes three values, this is the only ternary operator C has.

switch statement:The switch statement is much like a nested if .. else statement. Its mostly a matter of preference which you use, switch statement can be slightly more efficient and easier to read. Using break keyword:If a condition is met in switch case then execution continues on into the next case clause also if it is not explicitly specified that the execution should exit the switch statement. This is achieved by using break keyword.

Try out given example Show Example

What is default condition:If none of the listed conditions is met then default condition executed. Looping Loops provide a way to repeat commands and control how many times they are repeated. C provides a number of looping way. while loopThe most basic loop in C is the while loop.A while statement is like a repeating if statement. Like an If statement, if the test condition is true: the statements get executed. The difference is that after the statements have been executed, the test condition is checked again. If it is still true the statements get executed again.This cycle repeats until the test condition evaluates to false. for loopfor loop is similar to while, it's just written differently. for statements are often used to proccess lists such a range of numbers: do...while loopdo ... while is just like a while loop except that the test condition is checked at the end of the loop rather than the start. This has the effect that the content of the loop are always executed at least once. break and continue statements C provides two commands to control how we loop:
  • break -- exit form loop or switch.
  • continue -- skip 1 iteration of loop.
User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

Basic control structure available in c plus plus?

The basic control structure in C++ is the if statement.


What is the name of the structure type in C plus plus?

The same as in C, struct.


What is the Cdacl in c plus plus?

It's a wrapper for a discretionary access control list (DACL) structure. It is not part of the C++ standard, it's a Microsoft-specific class. Consult the MSDN for more information.


Do I need structure of turbo c plus plus?

Yes.


What is the price of the book data structure using c and c plus plus by tanenbaum?

225 Rs. after discount........


What is Counter Control in C plus plus?

Anybody can Help me PLEASE


What is objective of control structure and explain different control structre in c plus plus?

1.to clarify the program logic. 2. to serve as a guide for the program coding. 3. helps to identify alternative methods. BY. Brian Mwamuye Mwananje From Mombasa Kenya


Control statement in c plus plus?

Control statements are statements that alter the flow of execution according to the evaluation of an expression (the condition). The C++ control statements are ifstatements, switch statements and the tertiary conditional operator, ?:.


Can you give an example of a structure in C plus plus?

struct point { int x; int y; };


What is the general structure of a C plus plus Language?

The central feature of any C++ program is classes which can be used to express ideas directly in code.


What are the access control specifiers used in c plus plus?

The access control specifiers in C++ are...public - to denote that the member is accessible from any in scope codeprivate - to denote that the member is accessible only from within the containing classprotected - the same as private, except that derived classes are includedPrivate is the default for a class type object, while public is the default for a structure type object.


Basic structure of c n c plus plus?

The basic structure of a C or C++ program is built around types. A structure is a type. A function is a type. A class is a type. All of these types can be built from primitive (built-in) types and can be used to create ever-more complex types.