Question:

C Dev-C help PLZZZZZZZZZZZ

by  |  earlier

0 LIKES UnLike

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 <iostream>

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;

}

 Tags:

   Report

2 ANSWERS


  1. 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.


  2. So much wrong...  you really need to check your logic.

    And really, if you&#039;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&#039;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&#039;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&#039;s too much chance of a mistyping.

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.