Share
Explore BrainMass

Code analysis

In the following code snippet, what value will be printed for c and d before the loop is executed? What value will be printed afterward? Why do you feel that this will occur? (Code needed to make this a complete program intentionally left out.)

int c = 99;
int a[5];
int d = 12;
printf("c = %dn",c);
printf("d = %dn",d);
while (c < 3)
{
printf("%dn",c);
c++;
}
a[5] = 0;
printf("c = %dn",c);
printf("d = %dn",d);
printf("Donen");
c = getchar();

Solution Preview

Thias code snippet prints before the loop:
c = 99
d = 12

Thias code snippet prints after the loop:
c = 99
d = 12

And then it crashes.

a) The loop never executes, because ...

$2.19