MMGames Introduction to C C Language Development Environment C language now Useful Apps Contact Us
MMGames

Automatic version identification

SpineViewer

It's easy to tell by looking at it.

Response Time Checker

I can leave my computer on and do it.

Mouse cleaning time

I can leave my computer on and do it.

Mouse cleaning time

C language learned by 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?

program read-only
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.

Basic Knowledge (sample answers)

Solution 1-1
Counting Variable or Loop Variable


Solution 1-2
infinite loop

Program reading (example solution)

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.
Short Answer Type (Sample Answer)

Solution 4-1
The variable is initially filled with 1, and the variable is incremented by 1 each time, until it reaches a value of 1.
When the value of the variable becomes greater than the number of iterations, the loop is terminated.
A loop of constant times is realized.



About this Site

The C language (bitter C), which is learned by suffering, is
This is the definitive C language introductory site.
It systematically explains the basic functions of the C language and
It is as complete as or better than any book on the market.

Part 0: Program Overview
  1. What is the program?
Chapter 2: How to write a program
  1. Writing Rules
  2. Writing conventions
  3. Exercise 2
Chapter 3: Display on Screen
  1. String display
  2. newline character
  3. Exercise 3
Chapter 4: Numeric Display and Calculation
  1. Numeric Display
  2. Basic Calculations
  3. Type of value
  4. Exercise 4
Chapter 5: Numerical Memory and Calculation
  1. Memorize values
  2. Variable Type
  3. Type conversion
  4. Numeric justification
  5. Exercise 5
Chapter 6: Input from the keyboard
  1. Functions for input
  2. Fear of Input
  3. Exercise 6
Chapter 9: Repetition with a fixed number of times
  1. Sentences that repeat themselves
  2. Loop Operation Mechanism
  3. Exercise 9
Chapter 10: Unknown number of repetitions
  1. Loop of unknown frequency
  2. input check
  3. Exercise 10
Chapter 13: Handling Multiple Variables at Once
  1. Multiple variables are handled together.
  2. How to use arrays
  3. Exercise 13
Chapter 19: Dynamic Arrays
  1. Create arrays at will
  2. Exercise 19
Chapter 20: Multiple Source Files
  1. Minimal division
  2. The Stone of Partition
  3. Exercise 20

Comment
COMMENT

Open the 💬 comment submission box