﻿ Exercise 9 - Learning C with Suffering
C language learned by suffering

### Exercise 9

##### fundamental knowledge

Q1-1
What is the common name for a variable used to count the number of iterations in a for statement?

Q 1-2
What is commonly called a for statement that keeps repeating forever?

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 i, price;

scanf("%d", &price);

for (i = 1; i <= 9; i++) {
printf("%d Price Down = %d\n", i, (int)(price * ((10.0 - i) / 10)));
}

return 0;
}``````

##### program writing

Q3-1
Create a program that displays a multiplication table using a for statement.

Hint: You can use the %2d specifier to align the table.
Hint: You can use a for statement within a for statement.

##### descriptive expression

Q4-1
Briefly describe how the constant times loop of the for statement works.

Solution 1-1
Counting Variable or Loop Variable

Solution 1-2
infinite loop

Solution 2-1
A program that, upon entering a list price, displays prices with discounts from 1 to 9.

10.0 - i to obtain the discount rate, which is then divided by 10 to obtain the discount rate for calculation purposes.
##### Program writing (example of solution)

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

int main(void)
{
int x, y;

for (x = 1; x <= 9; x++) {
for (y = 1; y <= 9; y++) {
printf(" %2d ", x * y);
}
printf("\n");
}

return 0;
}``````

*I use printf("\n"); to break each line.
You may use any number of for statements, as well as other blocks (compound statements).
However, be mindful of the readability of the program.