C language learned by suffering
C language learned by suffering
Exercise 5
fundamental knowledge
Q1-1
What do you call naming a memory that stores numerical values?
Q 1-2
What do you call storing a number in the above location?
Q1-3
What do you call increasing the value of the above location by 1?
program read-only
How would the following program appear when executed?
Q2-1
#include <stdio.h>
int main(void)
{
int x, y;
x = 10;
y = x * 10 + 20;
printf("%5d\n", y);
return 0;
}
program writing
Q3-1
Buy one soft drink for 198 yen per bottle and two bottles of milk for 138 yen per bottle.
Find the change if the customer pays with a 1,000 yen bill.
However, add 5% consumption tax and the amount of change should be an integer.
You may or may not round off the consumption tax.
Find the change if the customer pays with a 1,000 yen bill.
However, add 5% consumption tax and the amount of change should be an integer.
You may or may not round off the consumption tax.
descriptive expression
Q4-1
3.14 * 12, and the computation by real numbers and integers, the answer is treated as a real number, briefly explain why.
Basic Knowledge (sample answers)
Solution 1-1
Variable Declaration
*The variable alone is correct.
Solution 1-2
assignment
Solution 1-3
increment
Program reading (example solution)
Solution 2-1
120
*%5d designation, so there will be a two-digit space in the front part.
Program writing (example of 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 yen\n", change);
return 0;
}
Solution 2-1
503 yen
It is possible to solve without using *variables, but it is easier to change them later if they are used.
*Points shall be deducted if the cast conversion is forgotten.
*Points will also be deducted if the answer is a real number.
*Answers differ slightly depending on the calculation method.
Short Answer Type (Sample Answer)
Solution 4-1
To prevent decimal places from being truncated.
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.