Challenge

Project 1

First i need to display the commodities in an array:

Say there are two vendors from whom the commodities/workstations are ordered, the individual prices and desired quantities of commodities are given in the following tables.

Person/Number of Commodities to be brought

Laptop

Mouse

Headset

Laptop Bag

Adapter

Ramu

5

15

10

5

20

Raju

10

10

25

10

15

Shyam

3

5

6

3

10

#include <iostream>
using namespace std;
int main()
{

int arr[3][5] ={

{5,15,10,5,20},
{10,10,25,10,15},
{3,5,6,3,10}
};
int i, j;
for (i = 0; i < 3; i++)
{
for (j = 0; j < 5; j++)

cout << *(*(arr + i) + j) << "\t";
cout <<"\n";
}
return 0;
}

Output:

Next i have to display the vendor price list:

Commodity/Commodity cost

Vendor1

Vendor2

Laptop

45000

43000

Mouse

1500

1200

Headset

2500

3000

Laptop Bag

1200

1000

Adapter

1600

1500

#include <iostream>
using namespace std;
int main()
{

int arr[2][5] ={

{45000,1500,2500,1200,1600},
{43000,1200,3000,1000,1500},
};
int i, j;
for (i = 0; i < 2; i++)
{
for (j = 0; j < 5; j++)

cout << *(*(arr + i) + j) << "\t";
cout <<"\n";
}
return 0;
}

Output:

Now i have to find the difference and find the best minimum difference:

#include <iostream>
#include<conio.h>

using namespace std;

int main()
{
int rowCount, columnCount, i, j;
int firstMatrix[10][10], secondMatrix[10][10], resultMatrix[10][10];

cout<<"Simple C++ Example Program for 2 D (dimensional) Array Matrix Subtraction Example\n";

cout<<"Number of rows of matrices to be subtracted : ";
cin>>rowCount;

cout<<"Number of columns matrices to be subtracted : ";
cin>>columnCount;

cout<<"Elements of first matrix : \n";

for (i = 0; i < rowCount; i++)
for (j = 0; j < columnCount; j++)
cin>>firstMatrix[i][j];

cout<<"Elements of second matrix : \n";

for (i = 0; i < rowCount; i++)
for (j = 0; j < columnCount; j++)
cin>>secondMatrix[i][j];

cout<<"Difference of entered matrices : \n";

for (i = 0; i < rowCount; i++)
{
for (j = 0; j < columnCount; j++)
{
resultMatrix[i][j] = firstMatrix[i][j] - secondMatrix[i][j];
cout<<resultMatrix[i][j]<<"\t";
}
cout<<"\n";
}

getch();

return 0;
}

output:

Hence the Vendor 2 is the best vendor.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.