Functions in C, Codeblocks error: expected '=', ',', ';', -
i'm working on code experience, coming across several errors in not understand, i've been programming month hence lack knowledge errors , coding.i can create program in main function but, want practice functions that's why designed program several functions.
s tut\lab\main.c|15|error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token| <--- ^^^^i'm encountering error in several lines, lines: 15,36,41,54,58.
this instructions program, if me great, in refining code(just compare on have done or missed) or how fix error. thanks
chatflow wireless offers customers 600 weekday minutes flat rate of 39.99. night (8 p.m. 7 a.m. ) , weekend minutes free, additional weekday minutes cost 0.40 each. there taxes of 5.25% on charges. write program prompts user enter number of weekday minutes, night minutes, , weekend minutes used, , calculates monthly bill , average cost of minute before taxes. program should display labels input data, pretax bill , average minute cost, taxes, , total bill. store monetary values whole cents (rounding taxes , average minute cost), , divide 100 display of results.
#include <stdio.h> #include <stdlib.h> #define flate_rate 39.99; /* basic water demand charge */ #define plan_minutes 600; /* charge per thousand gallons used */ #define add_minutes 0.40; #define tax 0.0525; void instruct; int compbill(int minutesused); void displaybill(double bill,double extracharge) int main() { int minutesused,weekendused,nightused,extracharge; int totalminutes = minutesused + weekendused + nightused; instruct(); printf("enter weekday minutes used (8am-7pm) : "); scanf(" %d",&minutesused); printf("enter weekend minutes used : "); scanf(" %d",&weekendused); printf("enter night minutes used : "); scanf(" %d",&nightused); int compbill(minutesused); displaybill(); return 0; } void instruct()){ printf("hello, welcome\n"); printf("i calculate total phone bill\n"); printf("we have flat rate of $%lf , $0.40 per weekday minute used\n",flate_rate); return; } int compbill(int minutesused){ double bill; double extracharge; if (minutesused>plan_minutes){ extracharge = ((double)minutesused - plan_minutes)*add_minutes; bill = extracharge + flate_rate; } else { bill = flate_rate; } return (bill); } void displaybill(){ prinf("your phone bill total $%lf ",bill); printf("you went on total minutes there's charge of %lf",extracharge); return; }
your issue use of semicolons on defines:
#define flate_rate 39.99; /* basic water demand charge */ #define plan_minutes 600; /* charge per thousand gallons used */ #define add_minutes 0.40; #define tax 0.0525;
when substituted, also include semicolon. never want this. instead should simply:
#define flate_rate 39.99 /* basic water demand charge */ #define plan_minutes 600 /* charge per thousand gallons used */ #define add_minutes 0.40 #define tax 0.0525
Comments
Post a Comment