Hi. I'm having a problem with two lines of code. In my first program, those two lines compiled with no problem. Now, as I redid the program to do arrays, now those two lines are giving me problems and I have not changed them. Here is my code with compile details. The offending lines are in main(), when I'm trying to multiply sale_comm.
rohan% vi project4.c
rohan% script output.out
Script started, file is output.out
rohan% cat project4.c
Code:#define ZERO 0.0 #define COMMISSION_RATE 0.144 #define BONUS_COMM_RATE 0.188 #define TRUE 1 #define FALSE 0 #define HIGH_SALESPERSON 7 #define ARRAY_SIZ 75 #include <stdio.h> int s_code[ARRAY_SIZ]; int c_code[ARRAY_SIZ]; double sale_amount[ARRAY_SIZ]; double sale_comm[ARRAY_SIZ]; int flag[ARRAY_SIZ]; void input_fun(); void output_fun(); int sales_code(); int cust_code(); double sale(); void comm_report (double comm, int bonus); void sale_error(); main() { int num_sales, n; double total_sales, total_comm; input_fun(); for (n =0; n < num_sales; n++) if (sale_amount[n] > 1450) { flag[n] = TRUE; sale_comm[n] = (208.8 + ((sale_amount - 1450) * BONUS_COMM_RATE)); } else { flag[n] = FALSE; sale_comm[n] = (sale_amount * COMMISSION_RATE); } total_sales += sale_amount[n]; total_comm += sale_comm[n]; s_code[n] = sales_code(); output_fun(); } void input_fun() { int n, num_sales; s_code[n] = sales_code(); while (s_code[n] != ZERO) { if (s_code[n] <= HIGH_SALESPERSON && s_code[n] > ZERO) { c_code[n] = cust_code(); sale_amount[n] = sale(); num_sales += 1; n++; } else { sale_error(); s_code[n] = sales_code(); } } return; } void output_fun() { int n, num_sales, flag; printf("\n\n SALES REPORT"); printf("\n\nSP CUST SALE COMM"); for (n = 0; n < num_sales; n++) { printf("%d %3d $%9.2lf\n", &s_code[n], &c_code[n], &sale_amount[n]); if (flag == TRUE) { printf("**"); } else { printf(" "); } printf(" $%9.2lf", &sale_comm[n]); } return; } int sales_code() { int sval; printf("\n\nSalesperson code (1-7)(Enter 0 to quit): "); scanf("%d", &sval); return sval; } int cust_code() { int cval; printf("Customer code: "); scanf("%d", &cval); return cval; } double sale() { double amount; printf("Sale amount in dollars and cents: "); scanf("%lf", &amount); return amount; } void sale_error() { printf("Salesperson code must be 1 to 7"); return; }
rohan% cc project4.c
"project4.c", line 35: operands must have arithmetic type: op "*"
"project4.c", line 40: operands must have arithmetic type: op "*"
cc: acomp failed for project4.c



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.