4737 - Babar - Lab-Task-01
4737 - Babar - Lab-Task-01
Solution
#include <iostream>
int main()
{
int arr[5];
cout << "Enter value at " << i << " index = ";
return 0;
}
2. Modify the solution of task 1 to print the elements of the array in
reverse order using a pointer.
Solution
#include <iostream>
int main()
{
int arr[5];
cout << "Enter value at " << i << " index = ";
return 0;
}
3. Create a class called Inventory having relevant data members and
methods such as addToInventory () and viewInventory (). Then
create a class called Item having relevant data members as well as
functions. An Inventory has many items. By making use of class
array/s and the concept of has a relationship, write a program in
C++.
Note: Constructors and getter/setters are mandatory.
Solution
#include <iostream>
#include <string>
class Item
{
private:
int itemID;
string itemName;
double price;
int quantity;
public:
Item() : itemID(0), itemName(""), price(0.0), quantity(0) {}
public:
Inventory() : itemCount(0) {}
int main()
{
Inventory inventory;
inventory.viewInventory();
return 0;
}