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

Practice Problem 14

Fundamentals

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 Manual

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.

descriptive

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)

Solution 2-1
ABCDEFGHIJKLMNOPQRSTUVWXYZ

"This displays A to Z by looping with a for loop."
問題
Program Documentation (Example Solution)

Solution 3-1
#include <stdio.h>
#include <string.h>

int main(void)
{
    char fname[256], name[256];

    printf("名字を入力して下さい:");
    scanf("%s", fname);

    printf("名前を入力して下さい:");
    scanf("%s", name);

    strcat(fname, name);
    printf("フルネームは %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]);
}

問題
descriptive (answer)

Solution 4-1
文字列はものによって長さがさまざまであるため、
長さを変えられるarrayを利用している。



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