Made with ScholarlyMake flashcards like these from your own notes
Question:What is an array?
Answer:An array is a data structure storing a fixed-size sequential collection of elements of the same type.
Question:What is the definition of an array?
Answer:A data structure storing a fixed-size sequential collection of elements of the same type.
Question:How do you declare a 1-D array in C?
Answer:int A[5];
Question:How do you declare a 2-D array in C?
Answer:int A[3][5];
Question:How do you initialize an array in C?
Answer:int A[5] = {1, 2, 3, 4, 5};
Question:How do you access an element in a 1-D array in C?
Answer:To access an element, you should define the array name and the location of the element in the array A[i].
Question:How do you access an element in a 2-D array in C?
Answer:To access an element, you should define the array name and two locations of the element in the array A[i][j].
Question:What is the role of an array name in C?
Answer:An array name is a pointer to the first element of the array.
Question:What is a string in C?
Answer:Strings are a sequence of characters in memory followed by the null character '\0'.
Question:How do you initialize and print a string in C?
Answer:Initialize a string like char text[] = "Hello World"; and print it with printf("%s", text);.
Question:What is the fgets() function in C?
Answer:The fgets() function reads at most one less than the number of characters specified by size from the given string and stores them in the string str.
Question:What are some common string library functions in C?
Answer:strlen(), strcpy(), strcat(), and strcmp().