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 11

fundamental knowledge

Q1-1
What do you call declaring a function form at the beginning of a program?


Q 1-2
What do you call a variable that you declare to pass a number to a function?


Q1-3
What do we call a number or variable that is passed to a function?


Q1-4
What do we call the number returned from a function?

program read-only
In the following program, what is the function tri for?
Answer judging from the processing details and variable names.

Q2-1
 #include <stdio.h>

int tri(int, int);

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

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

    return 0;
}

int tri(int side, int high)
{
    return side * high / 2;
}

program writing

Q3-1
Create a program that displays whether or not the Olympics will be held when the year of the year is entered.
However, the part that calculates the Olympic Games should be created as a separate function.

The summer games will be held in the year 2000, and every two years thereafter, in the order of winter->summer->winter->summer.
Also, this schedule is assumed to be eternally consistent.

descriptive expression

Q4-1
Briefly explain what is the purpose of creating the function.

Basic Knowledge (sample answers)

Solution 1-1
prototype declaration


Solution 1-2
dummy argument


Solution 1-3
actual argument


Solution 1-4
return value

Program reading (example solution)

Solution 2-1
Function to calculate the area of a triangle

Program writing (example of solution)

Solution 3-1
 #include <stdio.h>

int olympic(int year);

int main(void)
{
    int year, hold;

    scanf("%d", &year);
    hold = olympic(year);

    switch (hold) {
    case 0:
        printf("not opened\n");
        break;
    case 1:
        printf("Summer Olympics\n");
        break;
    case 2:
        printf("Winter Olympics\n");
        break;
    };

    return 0;
}

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

The return value of the *olympic function is mapped to the holding.
*Note that it is easy to forget the prototype declaration.
Short Answer Type (Sample Answers)

Solution 4-1
By creating functions for each function and combining them, the entire program can be completed.
This is because even large programs are easy to create.



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 more complete 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