Project #15459 - c++

4-13f. Here is part 4-13 part d, modify the code to produce parts b (separate header file student4-13.h for the structure definition, see fields in code to see data fields) and parts e and f (separate function for the printing of the array and pass the address of the array to a student pointer that will increment through the array, printing the student address label by accessing the fields through the arrow operator and making the for loop into a pointer comparison while loop).

**     d.    with an array of student structures

**     b.    with the structure definition in a separate header file
*      e.    with a function to print the array
**     f.    with a pass by reference (pointer to the array) to the function (using the arrow operator), using the pointer comparison while loop


#include<iostream>
#include"student4-13.h"   // define student and address structures
using namespace std;

void main()
{
    student s[2];  // array of two student structures
    int i, j;

    for (i = 0; i < 2; i++)
    {
    cout << "Enter Student First Name:  ";
    cin >> s[i].first;   // input into the ith student's first name field
    cout << "Enter Student Last Name:  ";
    cin.ignore(1, '\n');   // clear enter
    cin >> s[i].last;
    cout << "Enter Street Address:  ";
    cin.ignore(1, '\n');
    cin.getline(s[i].home.street, sizeof(s[i].home.street), '\n'); /* whole line for street*/
    cout << "Enter City:  ";
    cin.getline(s[i].home.city, sizeof(s[i].home.city), '\n');
    cout << "Enter State (ex. NY):  ";
    cin >> s[i].home.state;
    cout << "Enter Zip Code:  ";
    cin.ignore(1, '\n');
    cin >> s[i].home.zip;
    cout << "Enter Class Year:  ";
    cin >> s[i].year;
    cout << endl;
    }

            // pass student array to separate function - student pointer

    for (j = 0; j < 2; j++) // change to while pointer comparison loop
    {
    cout << "\n\n";    // change to print fields using pointer and arrow operator
    cout << s[j].first << " " << s[j].last << "  " << s[j].year << endl;
    cout << s[j].home.street << endl;
    cout << s[j].home.city << ", " << s[j].home.state << "  " << s[j].home.zip << endl;
    }

Subject Computer
Due By (Pacific Time) 10/27/2013 11:00 pm
Report DMCA
TutorRating
pallavi

Chat Now!

out of 1971 reviews
More..
amosmm

Chat Now!

out of 766 reviews
More..
PhyzKyd

Chat Now!

out of 1164 reviews
More..
rajdeep77

Chat Now!

out of 721 reviews
More..
sctys

Chat Now!

out of 1600 reviews
More..
sharadgreen

Chat Now!

out of 770 reviews
More..
topnotcher

Chat Now!

out of 766 reviews
More..
XXXIAO

Chat Now!

out of 680 reviews
More..
All Rights Reserved. Copyright by AceMyHW.com - Copyright Policy