Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

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 */
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

Comments

  • DB1DB1 Member Posts: 1,142
    : 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?
  • esskaybeeesskaybee Member Posts: 5
    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 */
    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("%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?
    :

  • Shawn CarterShawn Carter Member Posts: 0

    _______ [ http://forcoder.org ] free video tutorials and ebooks about { Assembly Ruby Python PL/SQL Perl Swift Visual Basic .NET Scratch Go MATLAB Visual Basic PHP C# C R Java Objective-C C++ Delphi JavaScript Bash Ada ML Apex Logo Clojure SAS Transact-SQL Scala Alice VBScript COBOL Lisp Lua Kotlin F# Fortran Dart Erlang Scheme FoxPro ABAP Prolog Hack LabVIEW Awk Crystal Julia D Rust } ______

Sign In or Register to comment.