help with this please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • charmeda103
    New Member
    • Oct 2008
    • 36

    help with this please

    i have to write a code for this:

    Coffee mugs sells for $3.49 each.
    write code that declares a variable in which to store the number of mugs and intitalizes it to mugs.

    Code:
     
    int=mugs;
    int=nomugs; 
    noMugs=0;
    is this right.

    also i have to write code that would declare an approprialtey named constant in which to store to that price.
    Code:
    const float=3.49
    int=mugs;
    int=total;
    is this code right
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    No, neither of those code segments is correct. To declare a variable, you type:

    Code:
    int myInt;
    char myChar;
    // etc...
    Your assignment in the first section is valid, but your assignment in the second section is right - your const float must have a name in addition to a value.

    Comment

    Working...