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


  Compared sentences   

  1. ..clause 1..: Conditional judgment
  2. ..clause 2..: Sentence that judges condition
  3. ..clause 3..: Operator for comparison

[1] Conditional judgment

Programs that had been made up to now were programs of all one-way traffic.
In a word, execute the sentence in the writing order from start to finish.
It was the simplest mechanism saying coming to ending if the sentence was lost.

If it is a really simple program, even this : though it manages to become.
It comes to a standstill at once when complex even a little processing is done.

Change the content of processing according to the condition to solve this problem.
There is money-> roast meat table d'hote and had - > bamboo basket Sova
The judgment on [noyouna] , condition is needed without fail.

In the world of computer, it is not ..the value of the numerical value.. ..another.. if it is said the condition.
In addition, only the comparison of two numerical values becomes a condition to put it concretely and it gets it.

It returns to contents.


[2] Sentence that judges condition

If ([ifu]) sentence is prepared in C language as a sentence judged according to the condition.
The if sentence compares the values of two numerical values, and does the processing division based on the result.
The usage of the if sentence becomes as follows.

 
If (conditional expression) Sentence;
The comparison of numerical values by the if sentence is very lucid and simple.
Only judge not be so. whether it is That is, the specified numerical value is 0
In C language, 0 is called the truth excluding the imitation and 0 when judged according to the condition.

[ The   truth   ]
It means numerical values (Even the negative value :) other than 0 by how to call the conditional judgment.

[   Imitation   ]
It means 0 by how to call the conditional judgment.
The specified numerical value executes it, and in the if sentence, the numerical value executes and only) situation but 0 executes the sentence on side ..the truth it.. ..(...
It flies the sentence, and execute the sentence after the if sentence when it is not so.
The numerical value must ..truth.. ..(.. display the numerical value the following program when the numerical value is only) but 0.
 
#include <stdio.h> 

int main(void)  
{
	int suuti = 10;  
	if (suuti) printf("%d\n",suuti);  
	return 0;
}
The execution result of this program becomes as follows.

10
In this program, int suuti=10;Though it makes
This is writing when substituting it at the same time as declaring.
Because the value of the variable is decided first, this writing might be called initialization.

[   Initialization   ]
Substitute the numerical value at the same time as declaring the variable.
In this program, the value of suuti Though nothing is displayed when making it to 0
When making it to other values, the value is displayed.

It returns to contents.


[3] Operator for comparison

The if sentence might be seen the sentence without the usage considerably only by reading the foregoing paragraph.
Anyway, only because whether 0 or not so can be judged.

However, if a usual calculation is combined with the if sentence, a more advanced comparison is possible.
For instance, when the number as which the value is the same is subtracted mutually, the answer : naturally It becomes 0.
If this character is used, the judgment of the value becomes possible by the subtraction.
Judge The following program uses the character, and the input number : 10.

 
#include <stdio.h> 

int main(void)  
{
	int suuti;  
	scanf("%d",&suuti);  
	If (suuti - 10) Printf ("The input value :  10 \n");  
	return 0;
}
This..program..execute..have..input..result..as follows..become.

10   Input data
It has ..the execution of this program.. and the result becomes as follows about .....

135   Input data
The input value 10. Then, it is not.
Though a very advanced comparison becomes possible, too, if this method is applied more complexly
The value of the variable : no matter how it thinks To examine it is ten
Saying as should the subtraction is unnatural.

Then, the operator only for the comparison is prepared in C language.
Use the == operator when you examine whether two numerical values are equal.
This operator calculates, that the result truly becomes it when two values are equal.


[   = and ==   ]
Even the professional has what makes a mistake in = and == carelessly well.
= A right, left numerical value is a comparison equal. the substitution of ..peel.. [hidari] for the variable and ==
First of all, doubt here when it doesn't move as thought.
The value input by the == operator : the following program It is an example of examining it is ten.
 
#include <stdio.h> 

int main(void)  
{
	int suuti;  
	scanf("%d",&suuti);  
	If (suuti == 10) Printf ("The input value :  10 \
	n");  return 0;
}
This..program..execute..have..input..result..as follows..become.

10   Input data
The input value,
The result when this program is executed and it inputs it excluding ten becomes as follows.

135   Input data
The judgment is neatly done though the correspondence of the display and non-display ahead is opposite.

It returns to contents.


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