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

Practice Problem 4

Fundamentals

Question 1-1
""で囲まれた文字列のことをなんと呼ぶか。


Question 1-2
"In mathematics, what symbol is used instead of the "×" symbol when writing in C?"


Question 1-3
What symbol is used in C language instead of the division symbol "÷" in mathematics?


Question 1-4
What notation is used in C to represent floating-point numbers?

Program reading
How will the program be displayed when executed?

Question 2-1
#include <stdio.h>

int main(void)
{
    printf("%d\n", 20 / 7);
    printf("%f\n", 20.0 / 7.0);
    return 0;
}

Program Manual

Question 3-1
Create a program that calculates 40 ÷ 13 and displays the expression, quotient, and remainder.

descriptive

Question 4-1
C languageでは、整数で割り算を行った場合、
割り切れないときには結果を切り捨てるが、
Explain it briefly.

Fundamentals (Answer Key)

Solution 1-1
String literal


Solution 1-2
*

※ Read as asterisk.

Solution 1-3
/

(※ Read as a slash.)

Solution 1-4
Floating-point

Program Reading (Solution Example)

Solution 2-1
2
2.857143

Please note that integer division truncates, rather than rounds.
"For real number answers, accuracy to two decimal places is sufficient."
問題
Program Documentation (Example Solution)

Solution 3-1
#include <stdio.h>

int main(void)
{
    printf("%d / %d = %d ... %d\n", 40, 13, 40 / 13, 40 % 13);
    return 0;
}

"Note that different symbols for division or remainder are also considered correct."
"While displaying the expression as a string is also considered correct, using a format specifier (%d) is preferable."
"Do not perform calculations; answers provided as strings will be marked incorrect."
問題
descriptive (answer)

Solution 4-1
四捨五入を行うと、商×割る数、の逆計算を行ったときに、
"This results in a contradiction where the result is larger than the original dividend."
Therefore,切り捨てにしたほうが矛盾が少なくなり、計算誤差を減らすことができるため



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