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


  Execution of two or more processing   

  1. ..clause 1..: Necessity of two or more processing
  2. ..clause 2..: Block sentence

[1] Necessity of two or more processing

I want to make the program that inputs the point of the test though it is sudden.
Though this can be easily achieved by the current having come
When it makes a mistake in a point that is larger than 100 points further this time and it inputs it
Apply the function of automatically correcting to 100 points and memorizing it.

This program is not difficult so much.
The following program is an example of achieving processing ahead.

 
#include <stdio.h> 

int main(void) 
{
	int score; 
	Printf ("Input the point");
	scanf("%d",&score); 
	if (score > 100) score = 100;  
	printf(It is "%d point point. \n",score); 
	return 0; 
}
The result when this program is executed and 100 or less is input becomes as follows.

Input the point: 58 The   input data.
The point It is 58 points.
The result when this program is executed and input that is larger than 100 is done becomes as follows.

Input the point: 135 The   input data.
The point It is 100 points.
Here, when further another one input point is larger than 100 points
"The input : Correct it because it is larger than 100. "
How should I do when I add the function like displaying the said message?

Naturally, it doesn't go well even if the printf sentence ties just behind an existing if sentence.
In the if sentence, the if sentence because only a certain sentence is used for the judgment result as follows soon
Every time, the printf sentence written just behind the if sentence is executed as a usual sentence.

One method is to use two if sentences. As follows

 if (score > 100) printf("The input : Correct it because it is larger than 100. \n"); if (score > 100) score = 100; 
If two if sentences are used, it becomes possible to display the message.

It returns to contents.


[2] Block sentence

Though two or more sentences can be executed for one condition if it makes it like the foregoing paragraph
Comparing it many times on the same condition only is useless and exists no matter how it thinks.
It smartens far if it is one if sentence, and there is a method by which two or more sentences can be executed.

In C language, the function to group two or more sentences exists.
It is a function that is called it a block sentence (complex sentence).


[   Block sentence   ]
Enclose..two or more..sentence..bring together..method.
It is possible to put two or more sentences on the place where only one sentence can be put or to do by using this block sentence.
Moreover, a little moving to the right and writing are the customs in the sentence in the block sentence.
Recall the person who has forgotten though it explained the indent in the start.

If the block sentence is used, two or more processing can be executed by the result of the if sentence.
The following program adds the message display function by using the block sentence.

 
#include <stdio.h> 

int main(void) 
{
	int score; 
	Printf ("Input the point");
	scanf("%d",&score); 
	if (score > 100) { printf("
		The input : Correct it because it is larger than 100. \n");  score = 
		100; 
	}
	printf(It is "%d point point. \n",score); 
	return 0; 
}
The result when this program is executed and 100 or less is input becomes as follows.

Input the point: 58 The   input data.
The point It is 58 points.
The result when this program is executed and input that is larger than 100 is done becomes as follows.

Input the point: 135 The   input data.
The input Correct it because it is larger than 100.
The point It is 100 points.

It returns to contents.


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