﻿ Exercise 7 - Learning C through Suffering
C language learned by suffering

### Exercise 7

##### fundamental knowledge

Q1-1
What do you call a non-zero number when making a conditional decision?

Q 1-2
What do you call 0 when making a conditional decision?

Q1-3
What do you call combining multiple statements by enclosing them in {{}}?

What is the next program to display?
Answer by judging from the process contents and variable names.

Q2-1
`````` #include <stdio.h>

int main(void)
{
int value, rest;

scanf("%d", &value);

rest = value % 2;

if (rest == 0) printf("E");
if (rest == 1) printf("O");

printf("\n");

return 0;
}``````

##### program writing

Q3-1
Enter a year, and it will tell you whether the Olympics will be held in that year or not.
Create a program that displays
If possible, it would be better if it could distinguish between summer and winter.
Hint: The Sydney Olympics (summer) were held in 2000.

The conditions are complicated, so please use the following
Ignore the previous years when the summer and winter seasons were in the same year.

##### descriptive expression

Q4-1
`` if (-1) printf("OK\n");``

When you run the above program, you will see OK, but
Briefly explain why.

Solution 1-1
true or true

Solution 1-2
false or false

Solution 1-3
Block or Double Sentence

Solution 2-1
Indicate whether the input value is odd or even.

O stands for odd and E for even.
The % calculates the remainder.
The last printf function is only for line breaking.
##### Program writing (example of solution)

Solution 3-1
`````` #include <stdio.h>

int main(void)
{
int year;

scanf("%d", &year);

if (year % 4 == 0) printf("Summer Olympics\n");
if (year % 2 == 0 && year % 4 ! = 0) printf("Winter Olympics\n");
if (year % 2 ! = 0) printf("No Olympics\n"); if (year % 2 == 0 && year % 4 !

return 0;
}``````

*Here, the year the Olympics are held is divisible by two.
In addition, we took advantage of the fact that it is also divisible by 4 during the Summer Olympics.
*Other calculation methods are possible, so the answer is correct if it is obtained by calculation.
*If the years are compared as they are without calculation, the answer is incorrect.
Question