MMGameslogo  MMGames
TwitterSharebutton  FacebookSharebutton   
learn through sufferingC Language
learn through sufferingC Language

Problem 7

Fundamentals

Question 1-1
What do we call numbers other than zero when making conditional judgments?


Question 1-2
What do we call 0 when it's used in conditional judgment?


Question 1-3
What do we call enclosing multiple sentences with {}?

Program reading
What is the purpose of the following program?
Determine the answer based on the processing content and variable names.

Question 2-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 Manual

Question 3-1
西暦yearを入力すると、そのyearにオリンピックが開かれるか、
Create a program to display.
If possible, it would be even better to display the distinction between summer and winter.
Hint: The Sydney Olympics (Summer) were held in 2000.

※条件がややこしくなるので、
"Let's disregard the times when summer and winter were in the same year."

descriptive

Question 4-1
if (-1) printf("OK\n");

When the program is executed, OK appears, but…
Explain it briefly.
Fundamentals (Answer Key)

Solution 1-1
True or true.


Solution 1-2
Fake or false


Solution 1-3
Block or compound sentence

Program Reading (Solution Example)

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

※ O is an abbreviation for odd, and E is an abbreviation for even.
% calculates the remainder.
"Note: The final printf function is only for adding a newline."
Program Documentation (Example Solution)

Solution 3-1
#include <stdio.h>

int main(void)
{
    int year;

    printf("西暦yearを入力して下さい:");
    scanf("%d", &year);

    if (year % 4 == 0) printf("夏季五輪\n");
    if (year % 2 == 0 && year % 4 != 0) printf("冬季五輪\n");
    if (year % 2 != 0) printf("五輪None\n");

    return 0;
}

"Here, the years in which the Olympics are held are divisible by 2."
"It also leveraged the fact that the Summer Olympics occur every four years."
"※Other calculation methods may be possible, so if you arrived at the answer through calculation, it will be considered correct."
"Incorrect answers will be given if you compare years directly without performing any calculations."
問題
descriptive (answer)

Solution 4-1
if文では、0以外のnumericsはすべて真と見なすので、
たとえ負の値であってもrunするから。



About This Site

Learning C language through suffering (Kushi C) is
This is the definitive introduction to the C language.
It systematically explains the basic functions of the C language.
The quality is equal to or higher than commercially available books.

Part 0: Program Overview
  1. What is a program?
Chapter 3: Displaying on the Screen
  1. String Display
  2. newline character
  3. Practice Problem 3
Chapter 4: Displaying and Calculating Numbers
  1. Display of numbers
  2. Basic calculations
  3. Numeric types
  4. Practice Problem 4
Chapter 6: Input from the Keyboard
  1. input function
  2. The fear of input
  3. Practice Problem 6
Chapter 9: Repeating a Fixed Number of Times
  1. Iterative sentence
  2. How Loops Work
  3. Practice Problem 9
Chapter 10: Repeating Without Knowing the Number of Times
  1. Unspecified loop
  2. Input validation
  3. Practice Problem 10
Chapter 13: Handling Multiple Variables at Once
  1. Handling multiple variables collectively.
  2. Arrays
  3. Practice Problem 13
Chapter 19: Dynamic Arrays
  1. Create arrays freely.
  2. Practice Problem 19