Lab 1
Lab 1
Class: BEE-15D
Fall 2023
Lab 1: Fundamentals of C++ arrays
Date: 19th September 2024
LAB TASK 1:
Create the following three one-dimensional arrays: Name, Age,
Grade - Allow the user to input the name, grade, and age of 5
students. - Find your name in the `name` array and then retrieve
LAB REPORT: OBJECT-ORIENTED PROGRAMMING 2
your age and grade from the respective index.
Task 1 output:
int main(){
struct Info{
int ID;
string street;
string city;
string state;
int bedrooms;
float bathrooms;
int squareFootage;
double pricepersqft;
};
int NUMOFPROPERTIES = 5;
Info property[NUMOFPROPERTIES];
property[0] = {1, "123 Main St", "Los Angles", "CA", 90001, 3, 2.5, 1500, 750000};
property[1] = {2, "456 Oak Ave", "San Francisco", "CA", 94102, 4, 3.0, 2000, 12000000};
property[2] = {3, "789 Pine Dr", "Seattle", "WA", 98101, 2, 1.5, 1200, 650000};
property[3] = {4, "101 Maple Blvd", "Portland", "OR", 97201, 3, 2.0, 1800, 800000};
property[4] = {5, "202 Birch Ln", "Austin", "TX", 73301, 4, 3.5, 2500, 950000};
int option;
cout << "Press 1 if you wish to view properties within a specified range. " << endl;
cout << "Press 2 if you wish to view all properties in order of increasing area." << endl;
switch(option) {
case 1: {
cout << "Enter lower limit and upper limit of your price range (separated by space):" << endl;
cout << " No. of bedrooms: " << property[i].bedrooms << endl;
cout << " No. of bathrooms: " << property[i].bathrooms << endl;
cout << " Square footage: " << property[i].squareFootage << " sq ft" << endl;
cout << " Price per square foot: $" << property[i].pricepersqft << endl;
break;
case 2: {
int minIndex = i;
minIndex = k;
if(minIndex != i) {
property[i] = property[minIndex];
property[minIndex] = temp;
cout << "Properties sorted by increasing area (square footage):" << endl;
cout << " Square Footage: " << property[i].squareFootage << " sq ft" << endl;
cout << " Price per square foot: $" << property[i].pricepersqft << endl;
break;
default:
return 0;