Squares Cube Table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • groovetopia
    New Member
    • Aug 2008
    • 1

    Squares Cube Table

    Hey I'm trying to make a table that ask users to enter a low number and high number. The program should calculate the square and cube for all number between the low and high. However my code won't compile. Any help?

    Code:
    #include <iostream>
    #include <string>
    #include <sstream>
    using namespace std;
    
    int main()
    
    {
      string mystr;
      int high=0;
      int low=0;
      int i=low;
      
      cout << "Math Table /n";    
      cout << "Enter low number: ";
      getline (cin,mystr);
      stringstream(mystr) >> low;
      cout << "Enter High number: " ;
      getline (cin,mystr);
      stringstream(mystr) >> high;
      
    for (low < high)
        printf("%8dNumber %8dSquare %8dCube\n ", i, i * i, i * i * i) ;
    
    return 0;
    }
  • oler1s
    Recognized Expert Contributor
    • Aug 2007
    • 671

    #2
    However my code won't compile
    Did you conclude that your code doesn't compile because you get a compiler error? It would be useful to copy-paste the error messages here, so we can read them and figure out what is wrong.

    Also, error messages contain a message, as the name suggests. We usually fix them by reading them, which indicate what is wrong in our program. The expectation is that you too can read an error message and fix your program, so if you cannot fix your program, tell us why. Could you not understand the error message? Did you understand it, but not see what in your code could have caused the error?

    We want you to learn, but if all you ask for is "fix my code", then you aren't learning, really.

    Comment

    • etiainen
      New Member
      • Aug 2007
      • 40

      #3
      oops, I almost gave him an answer... How do I delete a post btw?

      Comment

      • Laharl
        Recognized Expert Contributor
        • Sep 2007
        • 849

        #4
        You don't, only mods/admins can do that.

        Comment

        Working...