Thread: Help

  1. #16
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    You also need to initialize total to zero before you start adding values to it.
    Mainframe assembler programmer by trade. C coder when I can.

  2. #17
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    An IF condition must be enclosed in parens. Your curly braces surrounding the last two IF statements are not necessary.
    Mainframe assembler programmer by trade. C coder when I can.

  3. #18
    Registered User
    Join Date
    Oct 2009
    Posts
    32
    How about:

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    int num1;
    int num2;
    
    cout << "Please enter an integer between 0 and 100: ";
    cin >> num1;
    
    cout << "Please enter an integer between 50 and 100: ";
    cin >> num2;
    
    int total;
    for(int counter=num1;counter<num2;counter++)
    {
        total+=counter;
    }
    {
    if (num1 < 1 || num1 > 100) cout << "Please read and follow the directions!"  
    }
    {
    if (num2 <50 || num2 >100) cout << "Please read and follow the directions!"
    }
    
    cout << "The total of the intergers between " << num1 << " and " << num2 << " is " << total << end;

  4. #19
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    no, that's still wrong.

    you should at least try to compile your program before just asking the internet to fix your mistakes.

  5. #20
    beginner for now
    Join Date
    Oct 2009
    Posts
    35
    Code:
    int main ()
    {
         if (condition is true/*all other if's will be ignored*/)
         {do stuff - if it is true}
         
         else if (if condition if isn't true look here/*all other if's will be ignored*/) // 1. else if
         {do stuff - if it is true}
    
         else if (if condition else if /*1. else if*/isn't true look here)
         {do stuff - if it is true}
    
         else // if all if's aren't true use this
         {do stuff - always if all other if's aren't true}
    
         return 0; // don't forget on this one
    } // don't forget for this one you must close the braces
    
    // if you put this in compiler you'll get a lot of errors
    // I tried to put it in to human like to understand not computer
    Last edited by military genius; 10-14-2009 at 11:22 AM.

  6. #21
    Registered User
    Join Date
    Oct 2009
    Posts
    32
    thank you for your help. the situation I am in doesn't allow me access to a compiler. so i am trying to make due with doing this the best I can.


    So I cannot use this?

    Code:
    {
    if (num1 < 1 || num1 > 100) cout << "Please read and follow the directions!"  
    }
    {
    if (num2 <50 || num2 >100) cout << "Please read and follow the directions!"
    }
    Last edited by Titanguy; 10-14-2009 at 11:38 AM.

  7. #22
    Registered User
    Join Date
    Oct 2009
    Posts
    32
    aghhh, I am stuck

  8. #23
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    coding without a compiler is like drawing with no pencil.

    you need one. period.

    the situation I am in doesn't allow me access to a compiler. so i am trying to make due with doing this the best I can.
    this is just false.

    visual studio express is free, gcc is free, many others are free. get one. install it. compile.

  9. #24
    Registered User
    Join Date
    Oct 2009
    Posts
    32
    I just found an online compiler

  10. #25
    Registered User
    Join Date
    Oct 2009
    Posts
    32
    Ok, here is what I came up with now:


    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    int num1;
    int num2;
    
    
    cout << "Please enter an integer between 0 and 100: ";
    cin >> num1;
    
    cout << "Please enter an integer between 50 and 100: ";
    cin >> num2;
    
    int total = 0;
    for(int counter=num1;counter<num2;counter++)
    {
    total+=counter;
    }
    if (num1 < 1 || num1 > 100) cout << "Please read and follow the directions!"; 
    
    if (num2 <50 || num2 >100) cout << "Please read and follow the directions!";
    
    cout << "The total of the intergers between " << num1 << " and " << num2 << " is " << total << endl;
    }

  11. #26
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    431
    You can use GCC/G++ without making any changes to the computer you're using.
    Download MinGW (be sure to check the box for g++ and make if you need it) and copy the MinGW directory to a flash drive.
    On the computer you're going to be using, put in the flash drive, open up a cmd.exe (hit winkey+r and type cmd) and type
    set path=%path%;E:\MinGW\bin
    (Use the appropriate drive letter and path)
    You're good to go!
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

  12. #27
    Registered User
    Join Date
    Oct 2009
    Posts
    32
    how do you start the program?

  13. #28
    Registered User
    Join Date
    Oct 2009
    Posts
    32
    after I set the path, how do I set the path back to original?

  14. #29
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Titanguy View Post
    how do you start the program?
    By typing the name of the program.

  15. #30
    Registered User
    Join Date
    Oct 2009
    Posts
    32
    It didn't work. no big deal, but I set the path to:

    set path=%path%;E:\MinGW\bin


    How can I undo that, so nothing is changed on the computer?

Popular pages Recent additions subscribe to a feed