Explore BrainMass

Explore BrainMass

    Code analysis

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    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)
    a[5] = 0;
    printf("c = %dn",c);
    printf("d = %dn",d);
    c = getchar();

    © BrainMass Inc. brainmass.com October 9, 2019, 6:54 pm ad1c9bdddf

    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 ...

    Solution Summary

    The values which will be printed for c and d before the loop is executed are determined.