logo

Crowdly

Browser

Add to Chrome

Questions Bank (1456230 total)

Does the following array definition compile?

int x[5] = {1};
0%
0%
View this question

Given the following code fragment:

/*

The C standard library header <limits.h> provides macros that define

the range of each integer type [including the character types]

*/

#include <limits.h>

signed int x = INT_MAX;

write the exact value resulting from the evaluation of expression sizeof(x) when compiled using -bit GCC compiler.

View this question

Each element in an array must have the same _________________ as the others.

0%
0%
0%
0%
View this question

Given the following code fragment:

/*

The C standard library header <limits.h> provides macros that define

the range of each integer type [including the character types]

*/

#include <limits.h>

short int x = SHRT_MAX;

write the exact value resulting from the evaluation of expression sizeof(x) when compiled using -bit GCC compiler.

View this question

A function can return a value of type array.

0%
0%
View this question

Given the following code fragment:

/*

The C standard library header <limits.h> provides macros that define

the range of each integer type [including the character types]

*/

#include <limits.h>

unsigned int x = UINT_MAX;

write the exact value resulting from the evaluation of expression sizeof(x) when compiled using -bit GCC compiler.

View this question

Does the following array definition compile?

float x[5] = {1.1f, 2.2f, 3.3f, 4.4f, 5.5f};
0%
0%
View this question

Consider the following code fragment involving arrays. If the code fragment cannot be compiled, write [for compile-time error]. If the code fragment generates undefined behavior, write [for undefined behavior]. Otherwise, write the exact text printed to standard output stream.

int grades[5] = {10,20,30,40,50}, new_grades[5];

int i, sum;

new_grades = grades;

for (i = sum = 0; i < 5; ++i) {

sum += new_grades[i];

}

printf("%d", sum);

Brief side-note on undefined behavior: The C standard says that statements such as c = (b = a + 2) - (a = 1); and c = (b = a + 2) - (a = 1); cause undefined behavior [because we don't know whether the left or right operand of operator - is evaluated first]. When a program ventures into the realm of undefined behavior, all bets are off. The program may behave differently when compiled with different compilers. But that's not the only thing that can happen. The program may not compile in the first place, if it compiles it may not run, and if it does run, it may crash, behave erratically, or produce meaningless results. In other words, undefined behavior should be avoided like the plague.

View this question

Given the following code fragment:

/*

The C standard library header <limits.h> provides macros that

define the range of each integer type [including the character types]

*/

#include <limits.h>

unsigned char x = UCHAR_MAX;

write the exact value resulting from the evaluation of expression sizeof(x)Β when compiled using -bit GCC compiler.

View this question

Is the following array definition legal?

int x[4] = {1, 2, 3, 4, 5};
100%
0%
View this question