Welcome Guest | Sign in | Register

Home > C Programming > Arrays > Questions and Answers

01. Which of the following correctly accesses the seventh element stored in foo, an array with 100 elements?
A. foo[6]; B. foo[7];
C. foo(7); D. foo;

Answer and Explanation

Answer: foo[6];

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
02. Which of the following gives the memory address of the first element in array foo, an array with 100 elements?
A. foo[0]; B. foo;
C. &foo; D. foo[1];

Answer and Explanation

Answer: foo;

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
03. The statement which declares a character based array called letters of ten elements is,
A. letters : char[10]; B. char[10] letters;
C. char letters[10]; D. char array letters[0..9];

Answer and Explanation

Answer: char letters[10];

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
04. Assign the character value 'Z' to the fourth element of the letters array
A. letters[4] := "Z"; B. letters[3] = 'Z';
C. letters[3] = 'z'; D. letters[4] = "Z";

Answer and Explanation

Answer: letters[3] = 'Z';

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
05. Use a for loop to total the contents of an integer array called numbers which has five elements. Store the result in an integer called total.
A. Statement 1
for( loop = 0, total = 0; loop >= 4; loop++ )
total = total + numbers[loop];
B. Statement 2
for( loop = 0, total = 0; loop < 5; loop++ )
total = total + numbers[loop];
C. Statement 3
for( loop = 0, total = 0; loop <= 5; loop++ )
total = total + numbers[loop];
D. Cannot be determined

Answer and Explanation

Answer: Statement 2
for( loop = 0, total = 0; loop < 5; loop++ )
total = total + numbers[loop];

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
06. Declare a multi dimensional array of floats called balances having three rows and five columns.
A. float balances[3][5]; B. balances[3][5] of float;
C. float balances[5][3]; D. array of float balances[0..2][0..5];

Answer and Explanation

Answer: float balances[3][5];

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
07. Write a for loop to total the contents of the multi dimensional float array balances, as declared in question 4.
A. Statement 1
for( row = 0, total = 0; row < 3; row++ )
for( column = 0, total = 0; column < 5; column++ )
total = total + balances[row][column];
B. Statement 2
for( row = 0, total = 0; row < 3; row++ )
for( column = 0; column < 5; column++ )
total = total + balances[row][column];
C. Statement 3
for( row = 0, total = 0; row < 3; row++ )
for( column = 0; column < row; column++ )
total = total + balances[row][column];
D. Cannot be determined

Answer and Explanation

Answer: Statement 2
for( row = 0, total = 0; row < 3; row++ )
for( column = 0; column < 5; column++ )
total = total + balances[row][column];

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
08. Assign the text string "Hello" to the character based array words at declaration time.
A. char words[10] = 'Hello'; B. static char words[] = "Hello";
C. static char words["hello"]; D. static char words[] = { Hello };

Answer and Explanation

Answer: static char words[] = "Hello";

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
09. Assign the text string "Welcome" to the character based array stuff (not at declaration time)
A. strcpy( stuff, 'Welcome' ); B. stuff = "Welcome";
C. stuff[0] = "Welcome"; D. strcpy( stuff, "Welcome" );

Answer and Explanation

Answer: strcpy( stuff, "Welcome" );

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
10. Use a printf statement to print out the third element of an integer array called totals
A. printf("%d\n", &totals[3] ); B. printf("%d\n", totals[3] );
C. printf("%c\n", totals[2] ); D. printf("%d\n", totals[2] );

Answer and Explanation

Answer: printf("%d\n", totals[2] );

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum



Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.