Practice Problem 4
Basics
Question 1-1
What is the term for a string enclosed in "" ?
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.
explanatory
Question 4-1
In C, when performing integer division,
if the result cannot be divided evenly, it is truncated.
Explain concisely why this occurs.
if the result cannot be divided evenly, it is truncated.
Explain concisely why this occurs.
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
2.857143
Please note that integer division truncates, rather than rounds.
For real number answers, accuracy to two decimal places is sufficient.
Question
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 example)
Solution 4-1
When rounding, performing the inverse calculation of quotient × divisor results in a value greater than the original dividend, creating a contradiction. Therefore, rounding down reduces contradictions and minimizes calculation errors.
About This Site
Learning C language through suffering (Kushi C) isThis 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.




