Question: What is the output of the following C++ code: #include #include #include using namespace std; STUDENT() { printf(Studnet Name Credits Needed for Graduation ); printf(
What is the output of the following C++ code:
#include
#include
#include
using namespace std;
STUDENT()
{
printf("Studnet Name Credits Needed for Graduation ");
printf( " ");
for (int i - 1; i <= 3; i++) {
STUDENT
Student.InitStudent(i);
printf("%s ", Student.ReturnStudent_Name());
printf("%4d ", Student.Credit_Due());
}
};
//**********student.h header file************************
class STUDENT
{
private:
int Student_Number;
char Student_Name[20];
int Credit_Earned;
char Student_Phone[15];
public:
STUDENT()
{
};
void InitStudent(int S_N) {
Student_Number = S_N;
if (Student_Number == 1)
{
strcpy (Student_Name, "John ");
Credit_Earned = 60;
strcpy(Student_Phone, "123-1234 ");
}
if (Student_Number == 2)
{
strcpy(Student_Name, "Anne ");
Credit_Earned = 123;
strcpy(Student_Phone, "123-2345 ");
}
if (Student_Number == 3)
{
strcpy(Student_Name, "Greg ");
Credit_Earned = 90;
strcpy(Student_Phone, "123-7890 ");
}
}
char *ReturnStudent_Name()
{
return Student_Name;
};
char *ReturnStudent_Phone()
{
return Student_Phone;
};
int ReturnDueAmount()
int Due_Amount;
if ((Credit_Earned) < 120)
{
Due_Amount = 120 - Credit_Earned;
}
else {
Due_Amount = 0;
};
return (Due_Amount);
};
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
