Ads 468x60px

Saturday 10 December 2011

C++ program to calculate the sales of a salesman

This is a C++ program which will accept the total sales of three products by three sales man in a double dimensional array. And hence it will calculate the total sales of each sales man and total sales of each product.
Below the program that fulfills above description:

#include "iostream.h"
#include "conio.h"
main()
{
int sales, prod, i, j;
int array[3][3];
clrscr();
for (i = 0; i < =2; i++)
 {
  cout << "Enter the salesman " << i+1 << " product \n";
  for (j = 0; j < =2; j++ )
   cin >> array[i][j];
}
// Total sales of individual salesman
for (i = 0; i < =2; i++)
 {
  sales = 0;
  for (j = 0; j < =2; j++)
  sales =  sales + array[i][j];
  cout << "Total sales of salesman " <<  i+1  << " is " << sales << endl;
 }
 cout << endl;
 // Total of individual products
 for (i = 0; i < =2; i++)
 {
  prod = 0;
  for (j = 0; j < =2; j++ )
   prod =  prod + array[j][i];
  cout << "Total product of product " << i+1  << " is " << prod << endl;
 }
 return 0;
}

Source: www.LearnCandCpp.com

2 comments:

ishita said...

this is a c++ programming ques i am stuck with. please help me with a solution.

"Write a program to calculate the total salary of n employee and find who gets the highest salary.
Note:( Total salary= basic salary + hra(20 % of basic salary)+ da (30 % of basic salary)"

Ankit Sharma said...

@ Itisha,
That's a simple program. Just go to www.LearnCandCpp.com and ask your queries there.

Post a Comment