Answer to Question #58993 in C++ for aventador

Question #58993
Question 2
Figure below shows that Student is a structure consisting of four different objects. The figure below illustrates how a struct is declared, how its constituent data members are accessed, and how it can be passed as a parameter to a function. You need to calculate the grade point average from the given pointer1 and pointer2. We have the declaration:
Student s;
struct number
{
string firstName;
string 1astName;
int studentNum;
int pointer1;
int pointer2;
};
Write a program that produce an output that will call struct Student for last name, first name, pointer1 and pointer 2 for a student named Mary.
1
Expert's answer
2016-04-08T08:52:04-0400
#include<iostream>
#include<string>

using namespace std;

struct Student
{
string firstName;
string lastName;
int studentNum;
int pointer1;
int pointer2;
void print();
};
void Student::print()
{
cout << "Last name " << lastName << " first name " << firstName << " pointer1 " << pointer1 << " pointer2 " << pointer2 << endl;
}
double aver(Student s);
int main()
{
Student Mary;
Mary.firstName = "Mary";
Mary.lastName = "Green";
Mary.pointer1 = 5;
Mary.pointer2 = 4;
Mary.print();
cout << aver(Mary) << endl;
system("pause");
return 0;
}
double aver(Student s)
{
return (double)(s.pointer1 + s.pointer2) / 2.0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS