C language learned by suffering
C language learned by suffering
Exercise 13
fundamental knowledge
Q1-1
What do you call a method for handling variables of the same type together?
program read-only
What does the following program compute?
Answer based on the process contents and variable names.
Answer based on the process contents and variable names.
Q2-1
#include <stdio.h>
int main(void)
{
int data[] = { 79, 42, 39, 79, 13, 75, 19 };
int i, sum = 0, avg;
for (i = 0; i < sizeof(data) / sizeof(data[0]); i++) {
sum += data[i];
}
avg = sum / (sizeof(data) / sizeof(data[0]));
printf("%d\n", avg);
return 0;
}
program writing
Q3-1
Create a program that displays the 10 numbers entered from the end.
descriptive expression
Q4-1
Briefly explain what the greatest advantage of the array is.
Basic Knowledge (sample answers)
Solution 1-1
array (programming, programing)
Program reading (example solution)
Solution 2-1
The average value is calculated.
Program writing (example of solution)
Solution 3-1
#include <stdio.h>
int main(void)
{
int data[10];
int i;
for (i = 0; i < 10; i++) {
printf("Please enter the %dth number:", i);
scanf("%d", &data[i]);
}
for (i = 9; i >= 0; i--) {
printf("%d ", data[i]);
}
printf("\n");
return 0;
}
*Here the loop is turned in reverse order when displayed, but
It can also be written to reverse only the number to be displayed, as shown below.
Another way to write
for (i = 0; i < 10; i++) {
printf("%d ", data[9 - i]);
}
Short Answer Type (Sample Answer)
Solution 4-1
The ability to handle a large number of variables together by specifying the number as a variable.
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.