help! cant find whats missing on this missing function header (old-style formal list?)

closed account (DEv9GNh0)
//energy charges
#include <iostream.h>

int main();

{
float kwh, cost;
cout<<"enter meter reading:";
cin>>kwr;
if (kwh<500)
cost=10;
else if (kwh<500)
cost=10+(kwh-500)*0.5;
else if (kwh<1000)
cost=35+(kwh-1000)*0.03;
cout<<"the cost is:";
cin>>cost;
return 0
}
It's <iostream>, not <iostream.h>

What is that semi-colon doing at the end of

int main(); ? It should not be there.

Why is there no semi-colon on the end of return 0 ?

This condition
if (kwh<500)
is the same as this one
else if (kwh<500)

You are asking the user to enter the cost at the end, after you've already calculated it.

Your code is confused and inconsistent and implies that you don't really understand the syntax. You should go back to the tutorial and start learning C++.
Last edited on
Topic archived. No new replies allowed.