Vocabulary
English | Қазақ | Русский |
Function | Функция | |
Procedure | Процедура | |
Value parameter | Сандық параметр | Числовой параметр |
String | Жол | Строка |
Character Strings
A sequence of characters is often referred to as a character “string”.
A string is stored in an array of type char ending with the null character '\0 '.
Character vs. String
A string constant is a sequence of characters enclosed in double quotes.
For example, the character string:
char s1[2]="a"; //Takes two bytes of storage.
s1:
On the other hand, the character, in single quotes:
char s2= `a`; //Takes only one byte of storage.
s2:
a | \0 |
a |
Task 1
Answer the questions using Internet resources (videos, texts, images):
How to describe a string?
How to input a string?
How to output a string?
10
Descriptors:
Example 1
char message1[12] = "Hello world";
cout << message1 << endl;
message1:
char message2[12];
cin >> message2; // type "Hello" as input
message2:
Example 2: String I/O
String can be input using the extraction operator >>, but one or more white spaces indicates the end of an input string.
char A_string[80], E_string[80];
cout << "Enter some words in a string:\n";
cin >> A_string >> E_string;
cout << A_string << E_string
<< “\nEND OF OUTPUT\n";
Output:
Enter some words in a string:
This is a test.
Thisis
END OF OUTPUT
Task 2
Watch the video and write the functions for string manipulation.
13
Descriptors:
Task 3
Write a program to the first task of other group students.
15
Descriptors:
Task 4
Write a program to the second task of other group students.
16
Descriptors:
Материалы на данной страницы взяты из открытых источников либо размещены пользователем в соответствии с договором-офертой сайта. Вы можете сообщить о нарушении.