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


  Exercise 8   

  1. ..clause 1..: Basic knowledge
  2. ..clause 2..: Program readout
  3. Memo
  4. ..clause 4..: Description type
  5. ..clause 5..: Basic knowledge(example solution)
  6. ..clause 6..: Program readout(example solution)
  7. Memo(example solution)
  8. ..clause 8..: Description type(example solution)


[1] Basic knowledge


[  1-1  ]
What is the option that adds the sentence executed when the condition is an imitation to the if sentence?

[  1-2  ]
What is commonly called writing that combines the above-mentioned many sentences and uses it?

[  1-3  ]
What is the sentence used to divide the sentence processed according to the number?
Example solution

It returns to contents.


[2] Program readout


[  2-1  ]
For what display is the following program a program?
Judging from the content of processing and the variable identifier, answer.
 
#include <stdio.h> 

int main(void)  
{
	int year;  
	
	scanf("%d",&year);  
	
	if (year % 2 == 0) { if (year % 4 == 0) { printf("summer\
		n"); 
		} else { 
			printf("winter\n");  
		}
	} else { 
		printf("do not\n");  
	}

	return 0;
}
Example solution

It returns to contents.


Memo


[  3-1  ]
Make the program that displays the moon of the corresponding lunar calendar when you input the moon.
Display the message of something when you input the moon that doesn't exist.
The hint: Lunar calendar sequentially : in January.
January and February, Yayoi, and April, May, June, July, August, September, October, November, and December
Example solution

It returns to contents.


[4] Description type


[  4-1  ]
Why is the break sentence put after each case sentence in the switch sentence?
Moreover, describe concisely when it is at that this is unnecessary.
Example solution

It returns to contents.


[5] Basic knowledge(example solution)


[  1-1  ]
Else sentence

[  1-2  ]
Else-if sentence

[  1-3  ]
Switch sentence
You may write the switch-case sentence.
Problem

It returns to contents.


[6] Program readout(example solution)


[  2-1  ]
Display whether for the Olympics to be held when the age is input at the Christian era.
- The last problem was only rewritten by the if-else sentence.
Problem

It returns to contents.


Memo(example solution)


[  3-1  ]
 
#include <stdio.h> 

int main(void) 
{
	int month; 
	
	printf(..".. input the moon. "); 
	scanf("%d",&month); 
	
	switch (month) { case 1: 
		Printf ("January \n");
		break; 
	case 2: 
		Printf ("February \n");
		break; 
	case 3: 
		Printf ("Yayoi \n");
		break; 
	case 4: 
		Printf ("April \n");
		break; 
	case 5: 
		Printf ("\n in May");
		break; 
	case 6: 
		Printf ("June \n");
		break; 
	case 7: 
		Printf ("\n in July");
		break; 
	case 8: 
		Printf ("August \n");
		break; 
	case 9: 
		Printf ("Length moon \n");
		break; 
	case 10: 
		Printf ("God no moon \n");
		break; 
	case 11: 
		Printf ("November \n");
		break; 
	case 12: 
		Printf ("December \n");
		break; 
	default: 
		printf(There is no such moon .."... \n"); 
		break; 
	}

	return 0; 
}
- It is acceptable, and the switch sentence is suitable for the if sentence when a lot of diverging.
- When the default sentence is lacked, it is assumed that it gives a demerit mark.
Problem

It returns to contents.


[8] Description type(example solution)


[  4-1  ]
The switch sentence : only of the jump to the case sentence to the end because it can do nothing but function.
It is necessary to slip out the entire ending switch sentence of each case sentence putting the break sentence.
However, you may tie as it is when there is a common feature in the processing of each case sentence.
Problem

It returns to contents.


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