Skip to main content

C Decision Making Statements

 C CONTROL STATEMENTS

Control Statements in C language enable to determine flow of program using various kind of statement.In c language mostly program executed by sequence but control statements can change flow of program by making jump within program.

  3 Types of Control Statements are 




Decision Making Statements:- This Statements is also called conditional statements.In C language normally program executes in sequence but some times there are number of situation where programmer needed to change the sequence .This involved decision making to see whether particular condition is true or not.
          
Flow Chart Of Decision  Making Statements



Decision Making Statements support following statements:-

1.If Statement
2.If else Statement
3.If else if Statement
4.Nested if Statement
5.Switch Statements

1.If Statement:-  In C is used to if statements to control the program flow based on the condition. if statement is used to check the one or more condition.And In C if statements tests the condition. It executes the if block if condition is true.
Syntax 
if(condition)
{
//code to be executed
}
                                    if statements flow chart                                                
Flow chart of  if statements

 2.If-else statements:- The C if-else statement tests the condition.It execute the block if condition is true otherwise else block is executed.we can perform two operation in a single condition. that is one is for the true of that condition, and other for the false  of the condition.both block are cannot be executed in simantansouly. 
Syntax:-
if(condition)
{
//code to be executed if condition is true
}
else
{
//code to be executed if condition is false
}
                   if-else statement flow chart 




3.If else-if statement:-The if-else-if statement execute one condition from multiple statements. 
Syntax:-
if(condition 1)
{
//code to be executed if condition is true
}
else if(condition 2)
{
//code to be executed if condition is true
}
else if (condition 3)
{
//code to be executed if condition is true
}
else
{
//code to be executed if all the condition are false
}
                flow chart of if else-if statement 




4. Nested if statement:- The nested if statements represents the if block within another if block. the nested block condition executes only when outer if block condition is true. 
syntax:-
if(condition)
{
//code to be executed
if(condition)
{
// code to be executed
}
}
5.Switch Statement

The switch statements execute one statements from multiple condition.  

Rules of switch statement

πŸ‘‰πŸ» Switch expression and case value must be integer and character type.
πŸ‘‰πŸ»Case value must be consider within switch statement.
πŸ‘‰πŸ»The break statement in switch case is not must it is optional.

Syntax:-
switch(expression)
{
case value 1:
//code to be executed;
break;
case value 2:
//code to be executed;
break;
case value 3;
//code to be executed;
break;
.......
default:
//code to be executed if all cases are not matched;
}
                        Flow chart of switch statement

Switch Statement is Fall Through:- Without break statement all the statements are executed this condition is called fall through.
Syntax:-
switch(expression)
{
case value 1:
//code to be executed;
case value 2:
//code to be executed;
.......
default:
//code to be executed if all cases are not matched;
}

               NEXT STATEMENT AVAILABLE SOON AS......

Comments

Popular posts from this blog

Rapid View Of Technology

  Currently Running Top 10 Programming Languages C programming language                         C language is the most popular and and widely used programming language.The C language is developed in 1972 by  Dennis Ritchie at bell laboratories of AT&T American Telephone & Telegraph, located in the U.S.A . C language is also knows as mother and structured programming language.C language is a basic language of all other languages. C++ programming language                                 C++ is object oriented programming language. C++ programming language was developed in 1980 by Bjarne Stroustrup  at bell laboratories of AT&T,located in U.S.A  . C++ is totally based on oops concept. HTML                              ...

Let's Be Technical

.   Programming Languages And There       Importance       Before you know about programming  language  we  must  know about languages. the language is a communication medium why which we can understand other person the language way of the transformation of various ideas and thoughts among people. After this  now we  know about programming language a programming language is a formal language, which comprises a set of instructions that produce various kinds of output. Programming languages are used in computer programming to implement algorithms. Most programming languages consist of instructions for computers. How its Importance of Programming Language Important in your daily life we use various device & tools that are works one the programming language like microwave ,ATM, Lift etc.  Programming language is important  because it define semantics and grammar which allow the pro...

C Language Tutorial

C Programming Language Tutorial        What is C Programming                              C Language is most popular and widely used programming language. C language is basic language of all other programming languages so also knows as mother language. that directly interact with the hardware devices like kernel and drivers. C is a Procedural language because solve the programming problem in step by step.  C language  break the program into function. C is a Structured language because break a program into several parts and blocks so that easy to understand this program.and break the program into several parts and blocks using function. C is a Mother language because base for other programming language.C language is also considered a several concepts like function, constructor, pointer etc. C is a Mid -level language bcz consider the feature of low-level and high-level p...