Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hey can someone please help me on this debugging problem? The following program

ID: 665187 • Letter: H

Question

Hey can someone please help me on this debugging problem?

The following program has build-time and runtime errors, as well as memory leaks. We need you to list all of these in the table below along with how you would fix them.

Program to Debug

1union values {

2    char w;

3    float x;

4    double y;

5}

6

7union values v = { 1.27 };

8

9struct card {

10    char suit[ 9 ];

11    int number;

12    char color[ 6 ];

13}

14

15struct person {

16    char lastName[ 15 ];

17    char firstName[ 15 ];

18    unsigned int age;

19}

20

21card c;

22

23person p;

24

25p = c;

Bugs Table

Identify each bug you find & provide the lines # where it happens. In addition, explain what the problem was, then how you fixed it.

Bug #

Lines #

Problem you identified

How you fixed it

1

Bug #

Lines #

Problem you identified

How you fixed it

1

Explanation / Answer

Modeified code :

union values {
char w;
float x;
double y;
};

union values v = { 1.27 };

struct card {
char suit[ 9 ];
int number;
char color[ 6 ];
};

struct person {
char lastName[ 15 ];
char firstName[ 15 ];
unsigned int age;
};

card c;

person p;

Bug# Line # Problem Identified How you fixed it 1 5 ';' was missing after union definition added ';'. 2 13 ';' was missing after struct definition added ';' 3 19 ';' was missing after struct definition added ';' 4 25 illegal assignment. p is of person type. It cannot hold c. so line 25 is invalid line 25 removed.