Here is the source code, and my problem is that I want to add a series of arrays, but I have no idea how to do it.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
//These Lines indicate the variables
int Computer,c,r,rm,hd,h,ram,RAM[4],HDD[5],comp=1,ramcount,hdcount,compcount=1,price[10],cpter;
float PriceBudget,MB,Monitor,Proc,VC,ODD,CC,KB,M,Price,totalpram,totalphdd,sumpc,sumpram,sumhdd,tpricehw;
printf(" ---This Program Will Help You Compute for the---\n");
printf(" ----Total Price in Assembling a Series of Computers----\n");
printf("\nPlease enter the Price Budget: ");
scanf("%d",&PriceBudget);
printf("\nPlease enter the number of Computers: ");
scanf("%d",&Computer);
//This is the start of the Code for the Computer loop
for (c=0;c<Computer;c++)
{
printf("\nPlease enter The Price of the Motherboard for Computer %d: " ,compcount);
scanf("%f",&MB);
printf("Please enter The Price of the Monitor for Computer %d: " ,compcount);
scanf("%f",&Monitor);
printf("Please enter The Price of the Processor for Computer %d: " ,compcount);
scanf("%f",&Proc);
printf("Please enter The Price of the Video Card for Computer %d: " ,compcount);
scanf("%f",&VC);
printf("Please enter The Price of the Optical Disk Drive for Computer %d: " ,compcount);
scanf("%f",&ODD);
printf("Please enter The Price of the Computer Case for Computer %d: " ,compcount);
scanf("%f",&CC);
printf("Please enter The Price of the Keyboard and Mouse for Computer %d: " ,compcount);
scanf("%f %f",&KB,&M);
printf("\nPlease enter the Number of RAM for Computer %d: " ,compcount);
scanf("%d",&rm);
sumpram=0;
ramcount=1;
//RAM Loop
for (r=0;r<rm;r++)
{
printf("Please enter Price of RAM %d for Computer %d: ",ramcount,compcount);
scanf("%d",&RAM[r]);
sumpram=sumpram+RAM[r];
ramcount++;
}
totalpram=sumpram;
printf("\nPlease enter the Number of Hard Drives for Computer %d: ",compcount);
scanf("%d",&hd);
hdcount=1;
sumhdd=0;
//Hard Drive Loop
for (h=0;h<hd;h++)
{
printf("Please enter Price of Hard Drive %d for Computer %d: ",hdcount,compcount);
scanf("%d",&HDD[h]);
sumhdd=sumhdd+HDD[h];
hdcount++;
}
totalphdd=sumhdd;
tpricehw=MB+Monitor+Proc+CC+KB+M+VC+ODD+totalpram+totalphdd;
compcount++;
}
if (tpricehw<=PriceBudget)
printf("\n The Price is %.2f. \n\n You Have Enough Budget!!\n\n" ,tpricehw);
else
printf("\n The Price is %.2f. \n\n You Need More Money.\n\n" ,tpricehw);
}
For example, in the first loop all the prices of the hardware will be added for computer 1, then after that for computer 2. My problem is that I want to add the total price of computer 1 and computer 2, but I'm having problems in determining how to do so.