Question:
C Dev-C help PLZZZZZZZZZZZ
juggalo_for_eva
2008-08-11 08:09:08 UTC
Hi I keep getting a error in my code
Im using Dev-C
It shows my block of code highlighted in brown
My code says: cout << "\nHow many MPG do you get?? ";
My whole code says:
typedef unsigned short USHORT;
#include

int main()
{
USHORT MPG;
USHORT gasPrice;
USHORT distanceTraveling;
USHORT howMuchItsGoingToCostYou

cout << "\nHow many MPG do you get?? ";
cin >> MPG;
cout << "\nHow far are you traveling?? ";
cin >> distanceTraveling;
cout << "\nWhats the price of gas where you live?? ";
cin >> gasPrice;

howMuchItsGoingToCostYou= (MPG / distanceTraveling) * gasPrice;
system( "PAUSE" );
return 0;
}
Three answers:
conehead
2008-08-11 08:23:49 UTC
So much wrong... you really need to check your logic.



And really, if you're getting an error and you want help, then post the error. Not psychic out here.



You need a ; after the def of howMuchItsGoingToCostYou

At least in my version of the language, you need a using namespace std; statement.



Your formula is wrong to calculate howMuchItsGoingToCostYou. You might try some simple numbers by hand.



And, at least where I am, gas prices aren't integers. Nor is it an integer when I figure how much it will cost. At least make them floats.



Since you never output anything, how will you know if it's working? If it were me, I would output whatever has been input (and you would have caught the integer problem with the gas price) and output the end result (and you would have seen there was an error in your formula).



And seriously, no one makes variable names like howMuchItsGoingToCostYou because there's too much chance of a mistyping.
Daniel B
2008-08-11 08:17:40 UTC
First you are missing a ; at the end of the line



USHORT howMuchItsGoingToCostYou



You will also need to put:



using namespace std;



At the top of your code.
rengifo
2016-10-21 15:38:59 UTC
the func is clrscr() desire it grow to be a typing mistakes. It needs the the hedder report conio.h pattern #contain #contain void important() { cout<<"try string"; //reflects the textual content in expenditures clrscr(); //clears the show and takes cursor to first line }


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...