Practice Problem 14
Basics
Question 1-1
What is the name for the method of distinguishing characters by assigning each a unique number?
Question 1-2
What do we call the special character that marks the end of a string?
Program reading
What will be displayed when the following program is executed?
Question 2-1
#include <stdio.h>
int main(void)
{
char C;
for (C = 'A'; C <= 'Z'; C++) {
printf("%C", C);
}
printf("\n");
return 0;
}
Program documentation
Question 3-1
Create a program that prompts the user to enter their family name and given name separately, then combines them and displays the full name.
explanatory
Question 4-1
Briefly explain why C uses arrays to handle strings.
Fundamentals (Answer Key)
Solution 1-1
character encoding
Solution 1-2
EOS or end-of-string character or \0
Program Reading (Solution Example)
Program Documentation (Example Solution)
Solution 3-1
#include <stdio.h>
#include <string.h>
int main(void)
{
char fname[256], name[256];
printf("Please enter your last name.:");
scanf("%s", fname);
printf("Please enter your name.:");
scanf("%s", name);
strcat(fname, name);
printf("Full name is %s\n", fname);
return 0;
}
Here, we are concatenating strings before displaying them.
We could also consider how to arrange them when displaying them like this.
Solution 3-1, Alternative Solution
for (i = 0; i < 10; i++) {
printf("%d ", data[9 - i]);
}
Question
descriptive (answer)
Solution 4-1
Since strings vary in length depending on the item, we are using an array whose length can be changed.
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.




