Okay i just want to ask u guys if i am on the rihgt track....
Question).Use a double-subscript array to solve the following problem.A company has four salespeople (1to4) who sell five different products ( 1 to 5).Once a day, each salesperson passes in a slip for each different type of product sold.Each slip contains:
1. The salesperson number
2. The product number.
3.The total dollar value of that product sold that day.
Thus, each salesperson passes between 0 and 5 sales slip per day.Assume that the information from all of the slips for last month are available.Write a program that will read all this information for the last month's sales and summarize the total sales by salesperson by product.All totals should be stored in the double-subscript array sales.After processing all the information for last month, print the result in a tabular format with each of the colums representing a particular salesperson and each of the rows representing a particular product.Cross total each row to get the total sales of each product for the last month; cross total each colum n to get the total sales by salesperson for last month.Your tabular printout should include these cross totals to right of the of the totaled rows and the bottom of the totaledcolumns.
Well if u guys just explain how the layout would look like that would help alot and here is my code ...Not tried the question yet but just printed the arrays out.......
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int sales[5][4]= {23,45,32,12,34,56,75,64,37,32,79,70,83,48,52,35,19,76,43,24};
int i, j;
printf (" Sales Person Number\n"
" [0] [1] [2] [3]\n");
for ( i =0; i <= 4; i++ ){
printf ("Product_Price[%d] ", i );
for ( j =0; j <= 3; j++ )
printf ("%-5d", sales[i][j] );
printf ( "\n" );
}
system("PAUSE");
return 0;
}
Well in this code i just tried some stuff out..I just wanted to know that do i understand the question is the code below doing alil bit what they are talking about though it might not work but i guess u should know what i am trying to do here ??
Code:
#include <stdio.h>
#include <stdlib.h>
int sales_by_product( int[] [4] );
int sales_by_person ( int[] [4] );
int main()
{
int a[5][4]= {23,45,32,12,34,56,75,64,37,32,79,70,83,48,52,35,19,76,43,24};
int sales [2][4]={0};
int i, j;
printf (" Sales Person Number\n"
" [0] [1] [2] [3]\n");
for ( i =0; i <= 4; i++ ){
printf ("Product_Price[%d] ", i );
for ( j =0; j <= 3; j++ )
printf ("%-5d", a[i][j] );
printf ( "\n" );
}
for ( i=0; i = 0; i++ ){
for ( j=0; j <=3; j++ ) {
sales[i][j]=sales_by_product( a[3][4] );
printf ("%d", sales[i][j] );
}
}
system("PAUSE");
return 0;
}
int sales_by_product ( int product[] [4] )
{
int row, column;
int cnt;
for ( row = 0; row <=0; row++ ){
for ( column= 0; column <= 3; column++ )
return ++product[row][column];
}
}
Thanks alot