In this class, I learned about one-dimensional array for containing the values.
Unlike general variables, one-dimensional arrangement can be accessed through an index to each space.
For example, if you declare five variables, each variable must be defined with a specific value.
However, if you declare a 1D array with five spaces only once, each value can be accessed through an index.
/* General Variables */
int A1 = 10;
int A2 = 20;
int A3 = 30;
int A4 = 40;
int A5 = 50;
/* One-dimensional Array */
int A[5] = {10, 20, 30, 40, 50};
In case of charater array, string values can be seperated by each letter with indexing.
/* General Variables */
char Char1 = 'H';
char Char2 = 'E';
char Char3 = 'L';
char Char4 = 'L';
char Char5 = 'O';
printf("%c \n", Char1);
printf("%c \n", Char2);
printf("%c \n", Char3);
printf("%c \n", Char4);
printf("%c \n", Char5);
/* One-dimensional Array */
char Str[6] = "HELLO";
printf("%s \n", Str);
printf("%c \n", Str[0]);
printf("%c \n", Str[1]);
printf("%c \n", Str[2]);
printf("%c \n", Str[3]);
printf("%c \n", Str[4]);
'Study Meeting > 빡공단 30기' 카테고리의 다른 글
[Day 14] 'Number Baseball Game' in C Programming (2) | 2023.01.16 |
---|---|
[Day 13] Repeated Statement: for and while (0) | 2023.01.13 |
[Day 12] Conditional Statement 2: switch - case (0) | 2023.01.12 |
[Day 11] Conditional Statement 1: if and else (0) | 2023.01.11 |
[Day 10] Operator 3: Bitwise Shift Operator (0) | 2023.01.11 |