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

  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 called the variable to which the value is not changed while programming it?

[  1-2  ]
What is called the simple function made by using the replacement function?
Example solution

It returns to contents.


[2] Program readout


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

#define TRI(A,H) ((A) * (H) / 2)  

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

	scanf("%d,%d",&side,&high);  
	printf("%d\n",TRI(side,high));  

	return 0;
}
Example solution

It returns to contents.


Memo


[  3-1  ]
It made it by exercise 11.
The Olympics must be held when you input the age at the Christian era or ..".. make the displayed program.
However, make the part where holding the Olympics is calculated as another function. 」
Return it by the enum constant of the return value of the function in addition based on the problem.
Example solution

It returns to contents.


[4] Description type


[  4-1  ]
The numerical value is written directly or though the variable only has to be used
Explain the reason in the use of the constant purposely indirectly why.
Example solution

It returns to contents.


[5] Basic knowledge(example solution)


[  1-1  ]
Constant

[  1-2  ]
Macro
Problem

It returns to contents.


[6] Program readout(example solution)


[  2-1  ]
Macro from which area of three corner type is requested.
Problem

It returns to contents.


Memo(example solution)


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

int olympic(int year);  

enum { OLYMIPC_NON, OLYMIPC_
	SUMMER, OLYMIPC_WINTER, 
};

int main(void)  
{
	int year,hold;  
	
	scanf("%d",&year);  
	hold = olympic(year);  
	
	switch (hold) { case OLYMIPC_NON: 
		Printf ("\n not opened");  
		break;  
	case OLYMIPC_SUMMER:  
		Printf ("Olympic Summer Games \n");  
		break;  
	case OLYMIPC_WINTER:  
		Printf ("Olympic Winter Games \n");  
		break;  
	};
	
	return 0;  
}

int olympic(int year)  
{
	if (year % 2 == 0) { if (year % 4 == 0) { return OLYMIPC_SUMMER; 
		} else { 
			return OLYMIPC_WINTER;  
		}
	} else { 
		return OLYMIPC_NON;
	}

}
- I think that I can actually feel that it is more comprehensible than it distinguishes by the numerical value.
Problem

It returns to contents.


[8] Description type(example solution)


[  4-1  ]
It becomes comprehensible because the name is named, and the change is prepared, too.
In addition, never change the value by mistake because the constant cannot be substituted.
Problem

It returns to contents.


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