Results 1 to 6 of 6

Thread: More problems from Aerials

  1. #1
    Aerials
    Guest

    Unhappy More problems from Aerials

    Once again, my code wont work lol
    so ca anyone help me? I dont know whats werong but the compiler acts weird

    Code:
    #include <iostream.h>
    #include <conio.h>
    
    int main()
    {
    char cont='c'
    int loop=0;
    for(loop=0;cont='c';loop++)
    {
    
    double length;
    double height;
    cout<<"This will calculate the area of a rectangle for you.\n"<<endl;
    cout<<"Enter the length of the rectangle: "<<endl;
    cin>>length;
    cout<<"Enter the height of the rectangle: "<<endl;
    cin>>height;
    cout<<"\n The area of the rectangle is: "<<(length*height)<<endl;
    
    cout<<"Press any key to exit"<<endl;
    }
    
    getch();
    getch();
    return 0;
    
    }
    Here's a screenshot of what the compiler says.

    Id appreciate the help
    Attached Images Attached Images  

  2. #2
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    char cont='c'


    needs a semicolon after it

  3. #3
    Aerials
    Guest
    doh!

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    BTW what is the loop variable for? Why not make a while loop?
    while(cont='c') ...
    where's the problem with this line of code?
    You need == !

    Oh, and you don't give the user a chance to "press any key to exit"...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5
    Aerials
    Guest
    i dunno
    i felt like doing a for

    if they press anything but c they quit

  6. #6
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    hmm where do you assign the value to cont than?
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width