Question: Download the attached file/s, copy and paste the code segment/s into your visual studio or any other C++ IDE and run it. You will have

Download the attached file/s, copy and paste the code segment/s into your visual studio or any other C++ IDE and run it. You will have to implement a small intentional bug in your program and post it for other students to debug.

To be able to receive your full discussion points, you need to submit the following.

Following is your check list and rubric

Attach your .cpp file/s with an implemented bug - 20pnts

Describe what the original code does in detail - 20pnts

Debug at least one other program and submit your .cpp file - 40pnts (note what the bug was in comments)

After running the debugged program, attach the screen shot of your output- 20pnts

// This program demonstrates a function that uses a

// pointer to a structure variable as a parameter.

#include

#include

#include

using namespace std;

struct Student

{

string name;

int idNum;

int creditHours;

double gpa;

// Student's name

// Student ID number

// Credit hours enrolled

// Current GPA

};

void getData(Student *); // Function prototype

int main() {

Student freshman;

// Get the student data.

cout << "Enter the following student data: ";

getData(&freshman); // Pass the address of freshman.

cout << " Here is the student data you entered: ";

// Now display the data stored in freshman

cout << setprecision(3);

cout << "Name: " << freshman.name << endl;

cout << "ID Number: " << freshman.idNum << endl;

cout << "Credit Hours: " << freshman.creditHours << endl;

cout << "GPA: " << freshman.gpa << endl;

return 0; }

//*******************************************************

// Definition of function getData. Uses a pointer to a *

// Student structure variable. The user enters student *

// information, which is stored in the variable. *

//*******************************************************

void getData(Student *s)

{

// Get the student name.

cout << "Student name: ";

getline(cin, s->name);

// Get the student ID number.

cout << "Student ID Number: ";

cin >> s->idNum;

// Get the credit hours enrolled.

cout << "Credit Hours Enrolled: ";

cin >> s->creditHours;

// Get the GPA.

cout << "Current GPA: ";

cin >> s->gpa;

}

Thank you in advance.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!