※スタイルシート未対応ブラウザではレイアウトを正確に再現できません。
  > | 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 6   

  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  ]
The function used to input the numerical value from the keyboard

[  1-2  ]
The sign put before the variable identifier : in the place where the above-mentioned function is used.
Example solution

It returns to contents.


[2] Program readout


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

int main(void)  
{
	int side,high,square;  

	scanf("%d,%d",&side,&high);  
	square = side * high / 2;  
	printf("%d\n",square);  
			
	return 0;
}
Example solution

It returns to contents.


Memo


[  3-1  ]
The price of one discount, three discounts, five discounts, and eight discounts when you input the fixed price
Make the program that does the list display.
The amount of money of the result doesn't care about the real number though the display by the integral value is preferable either.
Example solution

It returns to contents.


[4] Description type


[  4-1  ]
Actually, the scanf function is hardly used in the program for which reliability is necessary.
Explain it concisely why.
Example solution

It returns to contents.


[5] Basic knowledge(example solution)


[  1-1  ]
Scanf function
- It is other many.

[  1-2  ]

Problem

It returns to contents.


[6] Program readout(example solution)


[  2-1  ]
The program it that calculates the area of a triangle
It understands from the content of the variable identifier (vicinity and height and area) and processing (vicinity × height ÷2).
- Even if the reason is not described, it is assumed that it answers correctly.
- Do not only numerate the program mechanically however slowly.
  Come to be able to read it including the meaning of the program.
Problem

It returns to contents.


Memo(example solution)


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

int main(void) 
{
	int price; 
	
	Printf ("Input the fixed price");
	scanf("%d",&price); 
	
	Printf ("One discount = %d yen \n" (int) 
	(price * 0.9));
	Printf ("Three discounts = %d yen \n" (int) 
	(price * 0.7));
	Printf ("Five discounts = %d yen \n" (int) 
	(price * 0.5));
	Printf ("Eight discounts = %d yen \n" (int) 
	(price * 0.2));

	return 0; 
}

Input the fixed price: 198.
One discount = 178 yen
Three discounts = 138 yen
Five discounts = 99 yen
Eight discounts = 39 yen
- If you want to specify that it is one discount though one discount is assumed to be 0.9 times here
  (int) It seems to be tenth or more [hi] and it becomes it if it is assumed (price * (1 - 0.1)).
- You may substitute it making the variable at each discount.
- The result may be a real number.
- There is somewhat possibility that the result is different depending on the computational method.
- Attention of leaving putting [ruwo] easily in variable by scanf function.
Problem

It returns to contents.


[8] Description type(example solution)


[  4-1  ]
The scanf function : because it cannot check the inputting error.
Problem

It returns to contents.


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