※スタイルシート未対応ブラウザではレイアウトを正確に再現できません。
  > | advanced by | contents  | that returns in <    
                   < [modosusu] > Color magazine monochrome light and shade   font predetermined, Gothic Ming-style type longhand   size Konaka large   standard  


  Divide in case of three or more.   

  1. ..clause 1..: The condition processes it in case of two or more cases.
  2. ..clause 2..: Writing that sees easily

[1] The condition processes it in case of two or more cases.

In the method of the current learning, two chose and was able to do only [no] processing ..one.. ..choice.. [naishi].
However, it is how much the actual necessity of three high [era**] judgment.

For instance, assume the relation between the admission fee and the age of a certain zoo was as follows.
Division Age Admission fee
Infant Three years old or less Free of charge
Child 4-12 years old 250 yen
Adult 13 years old or more 400 yen
Think about the program that displays a necessary admission fee when you input the age.
The following program is an example to make honestly by using the if sentence.

 
#include <stdio.h> 

int main(void) 
{
	int age; 
	Printf ("Age");
	scanf("%d",&age); 
	If (Age < =   3) Printf ("Infant: Free \n");If (Age > =   4 & age < =   12) Printf ("Child: 250 yen \
	n");If (Age > =   13) Printf ("Adult: 400 yen \n");
	return 0; 
}
Even this program : on the face of things though is seems to the problem.
If it is neither an infant it is nor a child when thinking well, it can surely be declared that it is an adult.
Similarly, if it is not an infant though only either who who is the child or adult is impossible
It seems to be useless to confirm the age purposely.

Only have to continue the if-else sentence to lose this uselessness.
In a word, in using the if sentence as an executable statement of the else sentence
The content judged immediately before can be made the best use of, and uselessness is lost.
The program that these those who think correct becomes as follows.

 
#include <stdio.h> 

int main(void) 
{
	int age; 
	Printf ("Age");
	scanf("%d",&age); 
	Infant..free.
	} else { 
		Child.
		} else { 
			Printf ("Adult: 400 yen \n");
		}
	}
	return 0; 
}
The point of this program is a point to use the if sentence for the sentence executed by the else sentence.
First of all, judge whether it is if sentence of the start, and it is an infant.
Judge whether it is a child next when it is not an infant.
Display it without judging it because it is surely an adult when you are not a child.

It returns to contents.


[2] Writing that sees easily

Though uselessness in processing was certainly lost in the program of the preceding clause
It was not able to be said that the program would see the compliment easily.
Moreover, to swerve to the right fast by the indent
It is expected to become harder to see when conditions increase more than three.

The method is only in the disregard of the indent to make it to the sentence that sees this easily.
The following program is an example of making easily to see in disregarding the indent.

 
#include <stdio.h> 

int main(void) 
{
	int age; 
	Printf ("Age");
	scanf("%d",&age); 
	Infant..free.
	} else if (age <= 12) { 
		Printf ("Child: 250 yen \n");
	} else { 
		Printf ("Adult: 400 yen \n");
	}
	return 0; 
}
In this program, the if sentence ties just behind the else sentence.
Therefore, this writing might be commonly called else-if sentence.

The place where this writing is good is not to become long sideways even if the condition how many increases.
Though it expands fast below in adding if to the else sentence
It becomes a program that sees comparatively easily because it never expands horizontally.


This is a special example of becoming legibly when the indent is disregarded.
One using the indent becomes legible in case of almost.

It returns to contents.


< - It is advanced -> | in | head that returns  to returning  next |.