Digital-Systems-Assignments/Assignment 7/main.c
2019-10-24 16:17:22 +02:00

33 lines
1.0 KiB
C

/*
* Student: S.K. Soekhlal
* Number: 4860632
* Assignment: 4.3
*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
int m,n,i,j,c; /*Declare Variables*/
double price[100]; /*Declare array price*/
int matrix[100][100]; /*Declare array matrix*/
scanf("%d",&n); /*Get amount of items*/
for(i = 0; i<n; i++){ /*Loop to get price for every item and store them into array price*/
scanf("%lf", &price[i]);
}
scanf("%d",&m); /*Get amount of customers*/
for(j = 0; j<m; j++){ /*Loop the following code for every custromer*/
for (c = 0; c < n; c++){ /*Loop to get amount of every item and store amount of customers and amount of items they buy in matrix*/
scanf("%d",&matrix[c][j]);
}
}
for (j = 0; j<m; j++){ /*Loop the following code for every custromer*/
float total = 0;
for(c = 0; c < n; c++){ /*Calculating total*/
total += matrix[c][j]*price[c];
}
printf("%.2f\n", total);
}
return 0;
}