Posted By:
11 Jun, 2013 12:13 am PDT

Decision making in C and C++

What are the ways to use decisions in a program?
Attachment:None


Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.

  • If
  • If Else
  • Switch

 Please watch the video for details....

Was it useful?  



Based on situations in our daily life , we all take a choice .

Based on a condition in the program , a choice is taken.

we use

if( condition )                                         // Only if the condition is true , then the program enters the loop.
{

//Statements to execute.

}

and

if( condition )                                       // only if the condition is true , then the control enters the loop, if the condition is not satisfied if skips the code.
{

//statements to execute ;

}
else                                                    // this is an else choice.. if the "if" block is not executed , then this loop is executed.
{
// statements to execute;
}

To understand switch please have a look at the attached document.

 

Attachment: switch.doc

Was it useful?  




Please login to reply to this problem.