You are on page 1of 31

LAB_3-4 OOP LAB

  
PROBLEMS OF C++
TASK NO 1:
CODE:
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
struct Students
{
string name;
string cnic;
char gender;
float cgpa;
};
struct section
{
Students student[38];
char sect_name;
string teacher;
};
int main()
{
int size1, size2,choice;
float temp;
string Name,Cnic;
char ch;
section* Section;
cout << "Enter the number of Sections:";
cin >> size1;
Section = new section[size1];
cout << "Enter the number of Students:";
cin >> size2;
int count = 0, n = 0,temp2;
for (int j = 0; j < size1; j++)
{
for (int i = 0; i < 40; i++)
{
Section[j].student[i].cgpa=-1;
}
for (int i = 1; i < 40; i++)
{
cin.ignore();
cout << "Enter the name of student: ";
getline(cin, Section[j].student[i].name);
cout << "Enter the CNIC of student: ";
cin >> Section[j].student[i].cnic;
cout << "Enter the Gender of student: ";
cin >> Section[j].student[i].gender;
cout << "Enter the Cgpa of student: ";
cin >> Section[j].student[i].cgpa;
if (i == size2)
{
temp2 = i+1;
i = 40;

1|Page
}
}
for (int i = 0; i < temp2; i++)
{
for (int k = i; k < temp2; k++)
{
if (Section[j].student[k].cgpa > Section[j].student[i].cgpa)
{
temp = Section[j].student[i].cgpa;
Section[j].student[i].cgpa= Section[j].student[k].cgpa;
Section[j].student[k].cgpa= temp;
Name = Section[j].student[i].name;
Section[j].student[i].name =
Section[j].student[k].name;
Section[j].student[k].name = Name;
ch = Section[j].student[i].gender;
Section[j].student[i].gender =
Section[j].student[k].gender;
Section[j].student[k].gender = ch;
Cnic = Section[j].student[i].cnic;
Section[j].student[i].cnic =
Section[j].student[k].cnic;
Section[j].student[k].cnic = Cnic;
}
}
}

size2 = size2 - 40;


cin.ignore();
cout << "Enter the name of Section : ";
cin >> Section[j].sect_name;
cin.ignore();
cout << "Enter the name of Teacher : ";
getline(cin, Section[j].teacher);
if (size2 <= 0)
j = size1;
}
while (count == 0)
{
cout << "What You want to do\n";
cout << "Press 1 for Updating data\n";
cout << "Press 2 for Displaying data\n";
cout << "Press 3 for Quit\n";
cin >> choice;
switch (choice)
{
case 1:
cout << "Enter the section:";
cin >> ch;
for (int i = 0; i < size1; i++)
{
if (Section[i].sect_name == ch)
{
cout << "Enter the cnic number of old student";
cin >> Cnic;
for (int j = 0; j < 40; j++)
{
if (Section[i].student[j].cnic == Cnic)

2|Page
{
cin.ignore();
cout << "Enter the name of new student:
";
getline(cin, Section[i].student[j].name);
cout << "Enter the CNIC of new student:
";
cin >> Section[i].student[j].cnic;
cout << "Enter the Gender of new student:
";
cin >> Section[i].student[j].gender;
cout << "Enter the Cgpa of new student:
";
cin >> Section[i].student[j].cgpa;
j = 40;
}
}
i = size1;
}
}
break;
case 2:
cout << "Enter the section:";
cin >> ch;
for (int i = 0; i < size1; i++)
{
if (Section[i].sect_name == ch)
{
cout << "Name" <<setw(25) << "CNIC Number" <<
setw(11)<<"Gender" << setw(12) << "Cgpa\n";
for (int j = 0; j < 40; j++)
{
if (Section[i].student[j].cgpa != -1)
{
cout << Section[i].student[j].name <<
setw(20) << Section[i].student[j].cnic << setw(11) << Section[i].student[j].gender <<
setw(12) << Section[i].student[j].cgpa << endl;
}
}
i = size1;
}
}
break;
case 3:
count = 1;
break;
default:
cout << "Invalid input\n";
}
}
system("pause");
return 0;
}

3|Page
OUTPUT:

TASK NO 2:
CODE:
#include<iostream>
using namespace std;
struct circle
{
float radius;
};
struct triangle
{
float base;
float height;
};
struct rectangle
{
float length;
float width;
};
float area_rectangle(rectangle r1);
float area_circle(circle c1);
float area_triangle(triangle t1);
int main()
{
int count = 0,choice;
circle C1;
triangle t1;
rectangle r1;

4|Page
float area;
while (count == 0)
{
cout << "Which area you want to find?\n";
cout << "Press 1 for Circle\n";
cout << "Press 2 for Triangle\n";
cout << "Press 3 for Rectangle\n";
cout << "Press 4 for Quit\n";
cin >> choice;
switch (choice)
{
case 1:
cout << "Enter the radius of circle: ";
cin >> C1.radius;
area = area_circle(C1);
cout << "Area of Circle: " << area << endl;
break;
case 2:
cout << "Enter the base of triangle: ";
cin >> t1.base;
cout << "Enter the height of triangle: ";
cin >> t1.height;
area = area_triangle(t1);
cout << "Area of triangle: " << area << endl;
break;
case 3:
cout << "Enter the Length of rectangle: ";
cin >> r1.length;
cout << "Enter the width of rectangle: ";
cin >> r1.width;
area = area_rectangle(r1);
cout << "Area of rectangle: " << area << endl;
break;
case 4:
count = 1;
break;
default:
cout << "Invalid Input\n";
}
}
}
float area_circle(circle c1)
{
float area;
area = 3.142857 * (c1.radius * c1.radius);
return area;
}
float area_triangle(triangle t1)
{
float area;
area = 0.5 * (t1.base * t1.height);
return area;
}
float area_rectangle(rectangle r1)
{
float area;
area = r1.length * r1.width;
return area;

5|Page
}

OUTPUT:

TASK NO 3:
CODE:
#include <iostream>
using namespace std;
struct item
{
string drink = "Press 1 for drink 60 RS";
int d_price = 60;
string burg = "Press 2 for Bruger 200 RS";
int b_price = 200;
string sweat = "Press 3 for sweats 120 RS";
int s_price = 120;
};
int main()
{
int count = 0, choice, price = 0, d = 0, b = 0, s = 0;
item i1;
while (count == 0)
{
cout << "What you want\n";
cout << i1.drink << endl;
cout << i1.burg << endl;
cout << i1.sweat << endl;
cout << "Press 4 for Bill\n";
cin >> choice;
if (choice == 1)
{
price = price + i1.d_price;
d = d + 1;
}
else if (choice == 2)
{
price = price + i1.b_price;

6|Page
b = b + 1;
}
else if (choice == 3)
{
price = price + i1.s_price;
s = s + 1;
}
else if (choice == 4)
{
cout << "You Buy\nNumber 0f drinks= " << d << endl;
cout << "Number of burgers= " << b << endl;
cout << "Number of sweats= " << s << endl;
cout << "Total bill: " << price << endl;
count = 1;
}
}
system("pause");
return 0;
}

OUTPUT:

7|Page
TASK NO 4:
CODE:
#include <iostream>
using namespace std;
struct student
{
int rollno;
string name;
int age;
string address;
};
void print14(student s[], int size);
void printeven(student s[], int size);
void printbyrollno(student s[], int size);
int main()
{
int size,count;
student* Students;
cout << "Enter the the numbers of students you want to enter: ";
cin >> size;
Students = new student[size];
for (int i = 0; i < size; i++)
{
cout << "Enter the name of student: ";
cin >> Students[i].name;
count = 0;
while (count == 0)
{
cout << "Enter the age of student: ";
cin >> Students[i].age;
if (Students[i].age > 10 && Students[i].age < 15)
count = 1;
else
cout << "Enter again\n";
}
cout << "Enter the rollno of student: ";
cin >> Students[i].rollno;
cout << "Enter the address of student: ";
cin >> Students[i].address;
}
print14(Students, size);
cout << endl;
printeven(Students, size);
cout << endl;
printbyrollno(Students, size);
system("pause");
return 0;
}
void print14(student s[], int size)
{
int count = 0;
cout << "The students having age 14\n";
for (int i = 0; i < size; i++)

8|Page
{
if (s[i].age == 14)
{
count = 1;
cout << s[i].name << " " << s[i].age << " " << s[i].rollno
<< " " << s[i].address << endl;
}
}
if (count == 0)
cout << "No record found\n";
}
void printeven(student s[], int size)
{
int count = 0;
cout << "The students having even rollno\n";
for (int i = 0; i < size; i++)
{
if (s[i].rollno % 2 == 0)
{
count = 1;
cout << s[i].name << " " << s[i].age << " " << s[i].rollno
<< " " << s[i].address << endl;
}
}
if (count == 0)
cout << "No record found\n";
}
void printbyrollno(student s[], int size)
{
int Rollno, count = 0;
cout << "Enter the rollno of student which yo want to display: ";
cin >> Rollno;
for (int i = 0; i < size; i++)
{
if (s[i].rollno == Rollno)
{
count = 1;
cout << s[i].name << " " << s[i].age << " " << s[i].rollno
<< " " << s[i].address << endl;
}
}
if (count == 0)
cout << "No record found\n";
}

9|Page
OUTPUT:

TASK NO 5:
CODE:
#include <iostream>
#include <string>
using namespace std;
struct book
{
int number;
string name;
string title;
int flag;
};
int main()
{
book books[10];
int count = 0, counter = 4, choice, number,total=0;
string title, name;
bool found = false;
books[0].title = "Discrete Mathematics";
books[1].title = "Fundamental of Physices";
books[2].title = "C++ Programming";
books[3].title = "Calculas";
books[0].name = "Kenneth H.Rosen";
books[1].name = "David Halliday";
books[2].name = "DS-Malik";
books[3].name = "Howard Anton";
books[0].number = 113;

10 | P a g e
books[1].number = 311;
books[2].number = 501;
books[3].number = 291;
books[0].flag = 1;
books[1].flag = 3;
books[2].flag = 2;
books[3].flag = 4;
while (count == 0)
{
cout << "Press 1 to Display book information\n";
cout << "Press 2 to Add a new book\n";
cout << "Press 3 to Display all the books in the library of a particular
author\n";
cout << "Press 4 to Display the number of books of a particular title\n";
cout << "Press 5 to Display the total number of books in the library\n";
cout << "Press 6 to Issue a book\n";
cout << "Press 7 to Quit\n";
cin >> choice;
switch (choice)
{
case 1:
cout << "Enter the Book accession number: ";
cin >> number;
found = false;
for (int i = 0; i < counter; i++)
{
if (books[i].number == number)
{
found = true;
cout << "Name of Author: " << books[i].name << endl;
cout << "Accession number: " << books[i].number <<
endl;
cout << "Title of book: " << books[i].title << endl;
cout << "Number of flags: " << books[i].flag << endl;
}
}
if (found == false)
cout << "No Record found\n";
break;
case 2:
cout << "Enter the Book accession number: ";
cin >> number;
found = false;
for (int i = 0; i < counter; i++)
{
if (books[i].number == number)
{
found = true;
books[i].number = books[i].number + 1;
cout << "Book add successfully\n";
}
}
if (found == false)
{
cout << "Name of Author: ";
cin >> books[counter].name;
cout << "Accession number: ";
cin >> books[counter].number;

11 | P a g e
cout << "Title of book: ";
cin >> books[counter].title;
cout << "Number of flags: ";
cin >> books[counter].flag;
cout << "Book add successfully\n";
counter++;
}
break;
case 3:
cin.ignore();
cout << "Enter the Book Author name: ";
getline(cin,name);
found = false;
for (int i = 0; i < counter; i++)
{
if (books[i].name == name)
{
found = true;
cout << "Name of Author: " << books[i].name << endl;
cout << "Accession number: " << books[i].number <<
endl;
cout << "Title of book: " << books[i].title << endl;
cout << "Number of flags: " << books[i].flag << endl;
}
}
if (found == false)
cout << "No Record found\n";
break;
case 4:
cin.ignore();
cout << "Enter the Book Title: ";
getline(cin, title);
found = false;
for (int i = 0; i < counter; i++)
{
if (books[i].title == title)
{
found = true;
cout << "Number of Books: " << books[i].flag << endl;
}
}
if (found == false)
cout << "No Record found\n";
break;
case 5:
for (int i = 0; i < counter; i++)
{
total = total + books[i].flag;
}
cout << "The total books in library= " << total << endl;
break;
case 6:
cout << "Enter the Book accession number: ";
cin >> number;
found = false;
for (int i = 0; i < counter; i++)
{
if (books[i].number == number)

12 | P a g e
{
found = true;
books[i].flag = books[i].flag - 1;
cout << "Book issued successfully\n";
}
}
if (found == false)
cout << "No Book found\n";
break;
case 7:
count = 1;
break;
default:
cout << "Invalid Input\n";
break;
}
}
system("pause");
return 0;
}

OUTPUT:

TASK NO 6:
CODE:
#include <iostream>
using namespace std;
struct employ
{
string name;
int salary;
int hours;

13 | P a g e
};
int main()
{
int hours;
char ch;
employ employess[10];
for (int i = 0; i < 10; i++)
{
cout << "Enter the name of employ: ";
cin >> employess[i].name;
cout << "Enter the Salary of employ: ";
cin >> employess[i].salary;
cout << "Enter the working hours of employ per day: ";
cin >> employess[i].hours;
cout << "Do you work for extra hours y/n: ";
cin >> ch;
if (ch == 'y' || ch == 'Y')
{
cout << "How many extra hours you worked";
cin >> hours;
employess[i].salary = employess[i].salary + (hours * 10);
}
}
for (int i = 0; i < 10; i++)
{
if (employess[i].hours <= 8)
employess[i].salary = employess[i].salary + 50;
if (employess[i].hours> 8&&employess[i].hours<=10)
employess[i].salary = employess[i].salary + 100;
if (employess[i].hours > 10)
employess[i].salary = employess[i].salary + 150;
}
cout << "Name salary\n";
for (int i = 0; i < 10; i++)
{
cout << employess[i].name << " " << employess[i].salary << endl;
}
system("pause");
return 0;
}

14 | P a g e
OUTPUT:

TASK NO 7:
CODE:
#include <iostream>
using namespace std;
struct Date
{
int day;
int month;
int year;
};
int main()
{
int choice,days;
Date date;
cout << "Enter the date\n";
cout << "Enter the day: ";
cin >> date.day;
cout << "Enter the month: ";
cin >> date.month;
cout << "Enter the year: ";
cin >> date.year;
cout << "What you want to do\n";
cout << "Press 1 for adding in date\n";
cout << "Press 2 for subtracting in date\n";

15 | P a g e
cin >> choice;
if (choice == 1)
{
cout << "How many days you want to add: ";
cin >> days;
for (int i = 0; i < days; i++)
{
if (date.month == 12 && date.day == 31)
{
date.year = date.year + 1;
date.month = 1;
date.day = 0;
}
if (date.day == 31 && (date.month == 1 || date.month == 3 || date.month
== 5 || date.month == 7 || date.month == 8 || date.month == 10))
{
date.month = date.month + 1;
date.day = 0;
}
if (date.day == 30 && (date.month == 4 || date.month == 6 ||
date.month == 9 || date.month == 11))
{
date.month = date.month + 1;
date.day = 0;
}
if (date.day == 29 && date.year%4 == 0 && date.month==2)
{
date.month = date.month + 1;
date.day = 0;
}
if (date.day == 28 && date.month == 2)
{
date.month = date.month + 1;
date.day = 0;
}
date.day = date.day + 1;
}
}
if (choice == 2)
{
cout << "How many days you want to Subtract: ";
cin >> days;
for (int i = days; i >0; i--)
{
date.day = date.day - 1;
if (date.month == 1 && date.day == 0)
{
date.year = date.year - 1;
date.month = 12;
date.day = 31;
}
if (date.day == 0 && (date.month == 12 || date.month == 5 ||
date.month == 7|| date.month == 10))
{
date.month = date.month - 1;
date.day = 30;
}

16 | P a g e
if (date.day == 0 && (date.month == 4 || date.month == 2 ||
date.month == 6 || date.month == 9 || date.month == 11 || date.month == 8))
{
date.month = date.month - 1;
date.day = 31;
}
if (date.day == 0 && date.year % 4 == 0 && date.month == 3)
{
date.month = date.month - 1;
date.day = 29;
}
if (date.day == 0 && date.month == 3)
{
date.month = date.month - 1;
date.day = 28;
}
}
}
cout << "New date is\n";
cout << date.day << "/" << date.month << "/" << date.year << endl;
system("pause");
return 0;
}

OUTPUT:

TASK NO 8:
CODE:

17 | P a g e
#include <iostream>
#include <string>
using namespace std;
struct student
{
string Name;
int Age;
string CNIC;
int RollNumber;
string City;
string BirthStar;
};
int main()
{
int size;
student* Student;
cout << "Enter the number of students: ";
cin >> size;
Student = new student[size];
for (int i = 0; i < size; i++)
{
cout << "Enter the data of " << i + 1 << " Student:\n";
cin.ignore();
cout << "Enter the Name of " << i + 1 << " student: ";
getline(cin,Student[i].Name);
cout << "Enter the Age of " << i + 1 << " student: ";
cin >> Student[i].Age;
cout << "Enter the CNIC of " << i + 1 << " student: ";
cin >> Student[i].CNIC;
cout << "Enter the Rollno of " << i + 1 << " student: ";
cin >> Student[i].RollNumber;
cout << "Enter the City of " << i + 1 << " student: ";
cin >> Student[i].City;
cout << "Enter the Birthstar of " << i + 1 << " student: ";
cin >> Student[i].BirthStar;
}
for (int i = 0; i < size; i++)
{
cout << "The data of " << i + 1 << " student:\n";
cout << "The Name of " << i + 1 << " student: " << Student[i].Name << endl;
cout << "The AGE of " << i + 1 << " student: " << Student[i].Age << endl;
cout << "The CNIC of " << i + 1 << " student: " << Student[i].CNIC << endl;
cout << "The Rollno of " << i + 1 << " student: " << Student[i].RollNumber
<< endl;
cout << "The CITY of " << i + 1 << " student: " << Student[i].City << endl;
cout << "The Birthstar of " << i + 1 << " student: " <<
Student[i].BirthStar << endl;
}
delete[] Student;
system("pause");
return 0;
}

18 | P a g e
OUTPUT:

19 | P a g e
20 | P a g e
TASK NO 9:
CODE:
#include <iostream>
#include <string>
#include<fstream>
using namespace std;
struct Player
{
string name;
int homeruns;
int hits;
};
Player input();
void output(Player players[], int size);
int main()
{
int count = 0, choice, num;
ifstream myfile;
myfile.open("file.txt");
Player players[10];
if (myfile.is_open())
{
for (int i = 0; i < 10; i++)
{
myfile >> players[i].name;
myfile >> players[i].homeruns;
myfile >> players[i].hits;
}
}
else
{
for (int i = 0; i < 10; i++)
{
cout << "Enter the data of " << i + 1 << " Player\n";
players[i] = input();
}
}
while (count == 0)
{
cout << "What you want to do:\n";
cout << "Press 1 for Update data of player\n";
cout << "Press 2 for Display data of players\n";
cout << "Press 3 for quit and Save data in file\n";
cin >> choice;
if (choice == 1)
{
cout << "Enter the Index of player which you want to update";
cin >> num;
cin.ignore();
cout << "Enter the name: ";
getline(cin, players[num].name);
cout << "Enter the homeruns: ";
cin >> players[num].homeruns;

21 | P a g e
cout << "Enter the hits: ";
cin >> players[num].hits;
}
if (choice == 2)
{
output(players, 10);
}
if (choice == 3)
{
ofstream file;
file.open("file.txt", ios::out);
for (int i = 0; i < 10; i++)
file << players[i].name << endl << players[i].homeruns <<
endl << players[i].hits << endl;
file.close();
count = 1;
}
}
}
Player input()
{
ofstream file;
file.open("file.txt", ios::app);
Player player;
cout << "Enter the name: ";
getline(cin, player.name);
cout << "Enter the homeruns: ";
cin >> player.homeruns;
cout << "Enter the hits: ";
cin >> player.hits;
file << player.name << endl << player.homeruns << endl << player.hits << endl;
cin.ignore();
return player;
}
void output(Player players[], int size)
{
for (int i = 0; i < 10; i++)
{
cout << "The Data of " << i + 1 << " Player:\n";
cout << "The name of Player: " << players[i].name << endl;
cout << "The Homeruns of Player: " << players[i].homeruns << endl;
cout << "The Hits of Player: " << players[i].hits << endl;
}
}

OUTPUT:

22 | P a g e
23 | P a g e
TASK NO 10:
CODE:
#include <iostream>
using namespace std;
struct drinks
{
string name;
float price;
int numbers;
};
int main()
{
int count = 0, choice;
float money, moneyearned = 0;
bool found = false;
drinks* drink;
drink = new drinks[4];
drink[0].name = "Cola";
drink[0].price = 0.75;
drink[0].numbers = 20;
drink[1].name = "Root Bear";
drink[1].price = 0.75;
drink[1].numbers = 20;
drink[2].name = "Grape Soda";
drink[2].price = 0.80;
drink[2].numbers = 20;
drink[3].name = "Cream soda";
drink[3].price = 0.80;
drink[3].numbers = 20;
while (count == 0)
{
cout << " Drink name Cost\n";
cout << "Press 1 for "<< drink[0].name << " " <<
drink[0].price << endl;
cout << "Press 2 for " << drink[1].name << " " << drink[1].price
<< endl;
cout << "Press 3 for " << drink[2].name << " " << drink[2].price <<
endl;
cout << "Press 4 for " << drink[3].name << " " << drink[3].price <<
endl;
cout << "\nPress 5 for Quit\n";
cin >> choice;
switch (choice)
{
case 1:
if (drink[0].numbers > 0)
{
found = false;
while (!found)
{
cout << "Enter the money: ";
cin >> money;
if (money > 0 && money <= 1)
found = true;
}

24 | P a g e
if (money >= 0.75)
{
drink[0].numbers = drink[0].numbers - 1;
cout << "Your change is: " << money - drink[0].price <<
endl;
moneyearned = moneyearned + drink[0].price;
}
else
cout << "Not enough money\n";
}
else
cout << "This drink sold out!\n";
break;
case 2:
if (drink[1].numbers > 0)
{
found = false;
while (!found)
{
cout << "Enter the money: ";
cin >> money;
if (money > 0 && money <= 1)
found = true;
}
if (money >= 0.75)
{
drink[1].numbers = drink[1].numbers - 1;
cout << "Your change is: " << money - drink[1].price <<
endl;
moneyearned = moneyearned + drink[1].price;
}
else
cout << "Not enough money\n";
}
else
cout << "This drink sold out!\n";
break;
case 3:
if (drink[2].numbers > 0)
{
found = false;
while (!found)
{
cout << "Enter the money: ";
cin >> money;
if (money > 0 && money <= 1)
found = true;
}
if (money >= 0.80)
{
drink[2].numbers = drink[2].numbers - 1;
cout << "Your change is: " << money - drink[2].price <<
endl;
moneyearned = moneyearned + drink[2].price;
}
else
cout << "Not enough money\n";
}

25 | P a g e
else
cout << "This drink sold out!\n";
break;
case 4:
if (drink[3].numbers > 0)
{
found = false;
while (!found)
{
cout << "Enter the money: ";
cin >> money;
if (money > 0 && money <= 1)
found = true;
}
if (money >= 0.80)
{
drink[3].numbers = drink[3].numbers - 1;
cout << "Your change is: " << money - drink[3].price <<
endl;
moneyearned = moneyearned + drink[3].price;
}
else
cout << "Not enough money\n";
}
else
cout << "This drink sold out!\n";
break;
case 5:
cout << "The total money Machine earned: " << moneyearned << endl;
count = 1;
break;
default:
cout << "Invalid Input\n";
}
}
delete[] drink;
system("pause");
return 0;
}

26 | P a g e
OUTPUT:

TASK NO 11:
CODE:
#include <iostream>
#include <string>
using namespace std;
struct Address
{
string house_no;
int street;
string City;
string Province;
};
struct student
{
string name;
Address address;
int Age;
float Gpa;
};
int main()
{
int size;
student* Students;

27 | P a g e
cout << "How much student you want to enter: ";
cin >> size;
Students = new student[size];
for (int i = 0; i < size; i++)
{
cin.ignore();
cout << "Enter the data of " << i + 1 << " student\n";
cout << "Enter the name: ";
getline(cin,Students[i].name);
cout << "Enter the House no: ";
cin >> Students[i].address.house_no;
cout << "Enter the Street no: ";
cin >> Students[i].address.street;
cout << "Enter the City: ";
cin >> Students[i].address.City;
cout << "Enter the Provice: ";
cin >> Students[i].address.Province;
cout << "Enter the Age: ";
cin >> Students[i].Age;
cout << "Enter the GPA: ";
cin >> Students[i].Gpa;
}
cout << "Name Age Gpa House# Street# City
Province\n";
for (int i = 0; i < size; i++)
{
cout << Students[i].name << " " << Students[i].Age << " " <<
Students[i].Gpa << " ";
cout << Students[i].address.house_no << " " <<
Students[i].address.street << " " << Students[i].address.City << " " <<
Students[i].address.Province << endl;
}
delete[] Students;
system("pause");
return 0;
}

OUTPUT:

28 | P a g e
29 | P a g e

You might also like