EZ Math Movie, Tutorials, Decisions, Nested If Statements


Nested means one within another.

Within the true block of an if statement, or within the true or false block of an if, else statement you can place other if or if, else statements. Such statements are said to be nested. Here is an example that shows how nested if and if, else statements look. The following code will decide what variable, a, b, or c, holds the greatest value. Assume all three variables hold different numbers.

if(a > b)
{
  if(a > c)
  {
    print('a is the greatest.');
  }  
}
else
{
  if(b > c)
  {
    print('b is the greatest.);
  }
  else
  {
    print('c is the greatest.);
  }
}

Running the example program

This program is simply meant to show how one if, else statement can be placed within the true or false block of another. It is not realy meant to do anything practical.

Understand that the simpler if statement can be nested, and if and if, else statements can be nested within each other.


The example program

0ptions
Angle measurement: Degrees Radians

Go on input

Bounds:
Sorry, apparently this browser does not support HTML 5 canvas tag graphics.
Printer

Edit: Runtime          View: Starter Suggestion

To runtime:

Storage:

Editor width: Normal Wide


		

	


		

	


		

	

And....

Next tutorial: And and or


All contents of EZ Math Movie are copyrighted: Copyright 2011, Edward A. Zobel. All rights reserved.



Other sites you may find interesting

Zona Land Education Like Math and Physics?

Zona Land Education offers explanations, diagrams, and animations on these topics.
And it is all presented in a clear and casual manner.

Here is the link: zonalandeducation.com




EZ Programing Demos Want to learn about programing computers?

EZ Programing Demos has an animated, slow motion, interactive programing language demonstrator.
The site presents basic ideas at a beginner's level.

Here is the link: ezprogramingdemos.com



Custom Search

Name:
Domain:

Name
0


Name:
Name
0