For C programming. Chose A for true, B for Flase. 1. The variable declaration is
ID: 3731920 • Letter: F
Question
For C programming. Chose A for true, B for Flase.
1. The variable declaration is correct: int theBoard[5][5][5][10];
2. The variable declaration is correct: char aBoard[10][5][5][5];
3. The statement initializes the array: int nums[3][2] = {{22, 44}, {66, 97}, {98,99}};
4. The following code prints out: The arrays are not equal int
theArray[4] = {1,3,5,6};
int secondArray[4] = {1,3,5,6};
if (secondArray == theArray)
printf("The arrays are equal");
else printf("The arrays are not equal");
Consider the following code snippet for questions 5-7
int sample[4][4]={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}};
5. Valid values of i for the code snippet sample[i][1]=i; are 0, 1, 2, 3, or 4.
6. sample[1][1] contains the value 2.
7. printf("%d ", sample[1]); will print one row of 4 values from the array
_____________________________________________________________________________________
Consider the following code snippet for questions 8-11
char name[10]= "Sarah";
char secondName[10];
int i=0;
while (name[i] != '')
secondName[i] = name[i++];
secondName[i] = name[i];
8. the character stored in name[3] is a
9. strlen(name) returns 5
10. islower(name[2]) returns 0
11. after the while loop ends, secondName contains Sarah
12. Two functions can have the same name and number of arguments. In other words the two function declarations are okay.
void myfunction(int arg1, char arg2) and int myfunction(char arg1, float arg2)
____________________________________________________________________________________________________
13. The following code gives as output : 13 10 7 4
int i; for (i=13;i>5;i=i-4) {
printf("%d ",i++);
}
______________________________________________________________________________
14. The following statement compiles and output: Hello
char letters[10] = {'o','l','l','e','H'};
int i;
for(i=strlen(letters); i>=0; i--) {
printf("%c", letters[i]); }
_____________________________________________________________________________________
15. The following code puts the value 2 into 5 positions of theArray:
int theArray[5];
int i;
for (i=0;i<5;i++)
theArray[i] = 2;
__________________________________________________________________________________
Consider the following code snippet for questions 16-20
struct Point { float xcoor; float ycoor; char quadrant; };
struct Point aStruct;
struct Point myArrayStructs[5];
16. myArrayStructs[3] is an instance of the struct Point that holds 2 floats, and 1 char.
17. aStruct.xcoor = 5.5; can be used to change the value in xcoor to 5.5.
18. aStruct->ycoor = -12.15; can be used to change the value in ycoor to 5.
19. If aStruct has values, myArrayStructs[2]=aStruct; will duplicate all of the information in aStruct and place copies into appropriate fields of myArrayStructs[2]
Explanation / Answer
1. The variable declaration is correct: int theBoard[5][5][5][10];
Ans A
2. The variable declaration is correct: char aBoard[10][5][5][5];
Ans A
3. The statement initializes the array: int nums[3][2] = {{22, 44}, {66, 97}, {98,99}};
Ans A
4. The following code prints out: The arrays are not equal int
Ans A
5. Valid values of i for the code snippet sample[i][1]=i; are 0, 1, 2, 3, or 4.
Ans B (the valid values fir i are 0,1,2,3 since the array size of sample is 4X4 )
6. sample[1][1] contains the value 2.
Ans B (the value at sample[1][1] is 6)
7. printf("%d ", sample[1]); will print one row of 4 values from the array
Ans B (it will print the memory address for sample[1])
8. the character stored in name[3] is a
Ans A
9. strlen(name) returns 5
Ans A
10. islower(name[2]) returns 0
Ans B
11. after the while loop ends, secondName contains Sarah
Ans A
12. Two functions can have the same name and number of arguments. In other words the two function declarations are okay.
void myfunction(int arg1, char arg2) and int myfunction(char arg1, float arg2)
Ans A (this is function overloading where two function have same name but same number of argument of different type)
13. The following code gives as output : 13 10 7 4
Ans B (it print 3 10 4)
14. The following statement compiles and output: Hello
Ans A
15. The following code puts the value 2 into 5 positions of theArray:
Ans A
16. myArrayStructs[3] is an instance of the struct Point that holds 2 floats, and 1 char.
Ans A
17. aStruct.xcoor = 5.5; can be used to change the value in xcoor to 5.5.
Ans A
18. aStruct->ycoor = -12.15; can be used to change the value in ycoor to 5.
Ans B (-> is used for pointer type variables for structure)
19. If aStruct has values, myArrayStructs[2]=aStruct; will duplicate all of the information in aStruct and place copies into appropriate fields of myArrayStructs[2]
Ans B
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.