Complete the code to declare a character array named name with space for 10 characters.
char name[[1]];The code declares a character array name with space for 10 characters using char name[10];.
Complete the code to initialize the character array word with the string "hello".
char word[] = [1];To initialize a character array with a string, use double quotes like "hello". Single quotes are for single characters.
Fix the error in the code to correctly print the first character of the array letters.
char letters[] = {'a', 'b', 'c'};
std::cout << letters[1] << std::endl;To access the first element of an array, use square brackets with the index: letters[0].
Fill both blanks to create a loop that prints each character in the array chars until the null character is found.
char chars[] = {'C', '+', '+', '\0'};
for (int i = [1]; chars[i] [2] '\0'; i++) {
std::cout << chars[i];
}The loop starts at index 0 and continues while the character is not the null character '\0'.
Fill all three blanks to create a character array greeting initialized with "Hi!" and print its length excluding the null character.
char greeting[] = [1]; int length = 0; while (greeting[2] != '\0') { [3]; } std::cout << length << std::endl;
The array is initialized with "Hi!". The loop uses greeting[length] to check each character until the null character and increments length with ++length.