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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started