Question: Given the C code fragment below: int h = 0; /* line 1 */ int g() { h = h + 1; return h; }

  1. Given the C code fragment below:

int h = 0; /* line 1 */

int g() { h = h + 1; return h; } /* line 2 */

int main() { /* line 3 */

int B[4] = { 7, 13, 19, 23 }; /* line 4 */

B[ g() ] = B[ g()] + B[ g() ]; /* line 5 */

} /* line 6 */

Describe what should happen when line 5 is executed. What should be the final values of the B array and the variable h?

Step by Step Solution

3.39 Rating (149 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets analyze the C code fragment step by step and describe what should happen when line 5 is execute... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!