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

Practice Problem 5

Fundamentals

Question 1-1
What do you call naming the memory where numbers are stored?


Question 1-2
What do you call storing numbers in a specific location?


Question 1-3
What do you call increasing the numbers at the aforementioned location by one?

Program reading
How will the program be displayed when executed?

Question 2-1
#include <stdio.h>

int main(void)
{
    int x, y;

    x = 10;
    y = x * 10 + 20;
    printf("%5d\n", y);

    return 0;
}

Program Manual

Question 3-1
1本198円の清涼飲料Water1本と、1本138円の牛乳2本を購入し、
Please give me the change from a thousand yen note.
However, a 5% consumption tax will be added, and the change will be rounded to the nearest whole number.
Consumers are free to round the consumption tax.

descriptive

Question 4-1
"When performing calculations with real numbers and integers, such as 3.14 * 12,"The answer is to be treated as a real number, but briefly explain why.

Fundamentals (Answer Key)

Solution 1-1
Variable declaration

"Variables alone are also considered correct."

Solution 1-2
Assignment


Solution 1-3
increment

Program Reading (Solution Example)

Solution 2-1
 120

"Since it's a %5d format specifier, there will be a two-digit space in the preceding part."
Program Documentation (Example Solution)

Solution 3-1
#include <stdio.h>

int main(void)
{
    int juice, milk, money, payment, change;
    double tax;

    juice = 198;
    milk = 138;
    money = 1000;
    tax = 1.05;

    payment = (int)((juice + milk * 2) * tax);
    change = money - payment;

    printf("%d円\n", change);

    return 0;
}


Solution 2-1
503 yen

You can solve it without variables, but using them will make changes easier later.
"Points will be deducted if you forget to cast."
"Answers given as real numbers will also be penalized."
Depending on the calculation method, the answer may vary slightly.
descriptive (answer)

Solution 4-1
To prevent decimal numbers from being truncated.



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