# I NEED HELP FAST

Here is my code.

/* Program Name: Proj1MTB.c
* Programmer: Matt Berger
* Date: 9/18/02
* Purpose of Program: Is to calculate how many miles to the
gallon your vehicle can get. It can not run in batch mode,
it needs user to input there start miles,end miles,and
there gallons purchased.
*/

#include /* Printf, Scanf Definitions */

int
main(void)
{
int Startmileage, /* Input - Start Miles */
Endmileage; /* Input - End Miles */
double Gallonspurchased, /* Input - Gallons Purchased */
Milespergallon; /* Input - Miles Per Gallon */

/* Gets Start Miles */
scanf("%d", Startmileage);

/* Gets End Miles */
scanf("%d", Endmileage);

/* Gets Your Gallons Purchased */
scanf("%2.3f", Gallonspurchased);

/* Calculates Your Miles Per Gallon */
Milespergallon = (Endmileage - Startmileage)/Gallonspurchased;

/* Displays Your Miles Per Gallon */
printf ("Your vehicle gets %f miles per gallon.
", Milespergallon);

return (0);
}

I put it into Borland C compiler and it compile it and stuff but when I run it out of Borland nothing pops on the screen and in borland form 1 pops up can someone please help me? Its for class

• : Here is my code.
:
: /* Program Name: Proj1MTB.c
: * Programmer: Matt Berger
: * Date: 9/18/02
: * Purpose of Program: Is to calculate how many miles to the
: gallon your vehicle can get. It can not run in batch mode,
: it needs user to input there start miles,end miles,and
: there gallons purchased.
: */
:
: #include /* Printf, Scanf Definitions */
:
: int
: main(void)
: {
: int Startmileage, /* Input - Start Miles */
: Endmileage; /* Input - End Miles */
: double Gallonspurchased, /* Input - Gallons Purchased */
: Milespergallon; /* Input - Miles Per Gallon */
:
: /* Gets Start Miles */
: scanf("%d", Startmileage);
:
: /* Gets End Miles */
: scanf("%d", Endmileage);
:
: /* Gets Your Gallons Purchased */
: scanf("%2.3f", Gallonspurchased);
:
: /* Calculates Your Miles Per Gallon */
: Milespergallon = (Endmileage - Startmileage)/Gallonspurchased;
:
: /* Displays Your Miles Per Gallon */
: printf ("Your vehicle gets %f miles per gallon.
", Milespergallon);
:
: return (0);
: }
:
: I put it into Borland C compiler and it compile it and stuff but when I run it out of Borland nothing pops on the screen and in borland form 1 pops up can someone please help me? Its for class
:
I don't know too much about Borland, but if just an empty form pops up, perhaps you are creating the wrong type of project. Are you sure you're creating a console type application?
• Hi
I have given you the corrected code. Its mainly because of & missing which using scanf for integer, double values. Also, when you are reading a double value you are supposed to give %lf instead of %2.3f. Do revert once you get this
***********************************************************************
#include /* Printf, Scanf Definitions */

int main(void)
{
int Startmileage; /* Input - Start Miles */
int Endmileage; /* Input - End Miles */
double Gallonspurchased; /* Input - Gallons Purchased */
double Milespergallon; /* Input - Miles Per Gallon */

/* Gets Start Miles */
scanf("%d", &Startmileage);

/* Gets End Miles */
scanf("%d", &Endmileage);

/* Gets Your Gallons Purchased */
scanf("%lf", &Gallonspurchased);

/* Calculates Your Miles Per Gallon */
Milespergallon = (Endmileage - Startmileage)/Gallonspurchased;

/* Displays Your Miles Per Gallon */
printf ("Your vehicle gets %lf miles per gallon.
", Milespergallon);

return (0);
}

Thanks

***********************************************************************
: : Here is my code.
: :
: : /* Program Name: Proj1MTB.c
: : * Programmer: Matt Berger
: : * Date: 9/18/02
: : * Purpose of Program: Is to calculate how many miles to the
: : gallon your vehicle can get. It can not run in batch mode,
: : it needs user to input there start miles,end miles,and
: : there gallons purchased.
: : */
: :
: : #include /* Printf, Scanf Definitions */
: :
: : int
: : main(void)
: : {
: : int Startmileage, /* Input - Start Miles */
: : Endmileage; /* Input - End Miles */
: : double Gallonspurchased, /* Input - Gallons Purchased */
: : Milespergallon; /* Input - Miles Per Gallon */
: :
: : /* Gets Start Miles */
: : printf("Enter your start miles.");
: : scanf("%d", Startmileage);
: :
: : /* Gets End Miles */
: : printf("Enter your end miles.");
: : scanf("%d", Endmileage);
: :
: : /* Gets Your Gallons Purchased */
: : printf("Enter your gallons purchased.");
: : scanf("%2.3f", Gallonspurchased);
: :
: : /* Calculates Your Miles Per Gallon */
: : Milespergallon = (Endmileage - Startmileage)/Gallonspurchased;
: :
: : /* Displays Your Miles Per Gallon */
: : printf ("Your vehicle gets %f miles per gallon.
", Milespergallon);
: :
: : return (0);
: : }
: :
: : I put it into Borland C compiler and it compile it and stuff but when I run it out of Borland nothing pops on the screen and in borland form 1 pops up can someone please help me? Its for class
: :
: I don't know too much about Borland, but if just an empty form pops up, perhaps you are creating the wrong type of project. Are you sure you're creating a console type application?
: