ConstantChange
New member
I'm trying to find an average using 2 arrays. Seems simple enough. This is the approach I'm using....
for (model=1; model<4; model++)
printf("Average for model %d is %.2f\n", model, (model_sale[model-1])/(total_quanity[model-1]));
It compiles with zero errors, but when I tell the program I'm done entering the information and I want it to compute the average, I get an illegal operations error in DOS. The rest of the program runs fine is I leave the average part out.
Here is the screen output:
Please enter the model that you want to purchase.
1 for professional, 2 for office, and 3 for student model
1
Enter quanity:
25
Would you like to purchase more computers? 1 = Yes 2 = No
2
Average for model 1 is 1160.00
It should compute the average for model 2 and model 3, but the illegal error occurs and I have to shut down DOS shell
Is this a computer based problem or a logic error in my code?
(I can post the whole program if someone wanted to compile it on their computer and see if they get an error)
for (model=1; model<4; model++)
printf("Average for model %d is %.2f\n", model, (model_sale[model-1])/(total_quanity[model-1]));
It compiles with zero errors, but when I tell the program I'm done entering the information and I want it to compute the average, I get an illegal operations error in DOS. The rest of the program runs fine is I leave the average part out.
Here is the screen output:
Please enter the model that you want to purchase.
1 for professional, 2 for office, and 3 for student model
1
Enter quanity:
25
Would you like to purchase more computers? 1 = Yes 2 = No
2
Average for model 1 is 1160.00
It should compute the average for model 2 and model 3, but the illegal error occurs and I have to shut down DOS shell
Is this a computer based problem or a logic error in my code?
(I can post the whole program if someone wanted to compile it on their computer and see if they get an error)

Please Scroll Down to See Forums Below 











