CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2009
    Posts
    1

    compiling errors

    PHP Code:
    #include <iostream>
    #include <cstdlib>
    #include <ctime>
    #include <iomanip>
    using namespace std;

    int main() {
        
    int grade;
        
    int random1;
        
    int random2;
        
    int answer;

        
    // Introduce Program
        
    cout << "Math Tutor Menu " << endl;
        
    cout << " " << endl;

        
    cout << "1. First Grade " << endl;
        
    cout << "2. Second Grade " << endl;
        
    cout << "3. Third Grade " << endl;
        
    cout << " " << endl;

        
    // Get Grade
        
    cout << " Enter your grade (1-3): ";
        
    cin >> grade;

        
    // Get Problem to solve
        
    if (grade || grade 3) {
            
    cout << "Sorry you don't meet the requirments to use this program. " << endl;
        } else if (
    grade == 1) {
            
    random1 rand() 9;
            
    random2 rand() 9;
                 
    cout << " " << random1 << endl;
                 
    cout << "+" << random2 << endl;
        } else if (
    grade == 2) {
            
    random1 rand() 89 10;
            
    random2 rand() 89 10;
                
    cout << " " << random1 << endl;
                
    cout << "+" << random2 << endl;
        } else {
            
    random1 rand() 899 100;
            
    random2 rand() 899 100;
                
    cout << " " << random1 << endl;
                
    cout << "+" << random2 << endl;
        }
    //end if

        
    return 0;

    }
    //end main 
    PHP Code:
    1>c:\documents and settings\my documents\visual studio 2008\projects\mathtutor\mathtutor\mathtutor.cpp(31) : error C2143syntax error missing ';' before 'constant'
    1>c:\documents and settings\my documents\visual studio 2008\projects\mathtutor\mathtutor\mathtutor.cpp(32) : error C2143syntax error missing ';' before 'constant'
    1>c:\documents and settings\my documents\visual studio 2008\projects\mathtutor\mathtutor\mathtutor.cpp(36) : error C2143syntax error missing ';' before 'constant'
    1>c:\documents and settings\my documents\visual studio 2008\projects\mathtutor\mathtutor\mathtutor.cpp(37) : error C2143syntax error missing ';' before 'constant'
    1>c:\documents and settings\my documents\visual studio 2008\projects\mathtutor\mathtutor\mathtutor.cpp(41) : error C2143syntax error missing ';' before 'constant'
    1>c:\documents and settings\my documents\visual studio 2008\projects\mathtutor\mathtutor\mathtutor.cpp(42) : error C2143syntax error missing ';' before 'constant' 
    Now I am far from done with this program, but I cant continue until it lets me do this part of it. So if anybody can help. It would be much appreciated

  2. #2
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: compiling errors

    Code:
    random1 = rand() 9;
    Is this correct code, or parsed by PHP tag?
    Please use code tags to put C/C++ code, like this:

    [code]Code here[/code].

    If this is original code, you need to change it :
    Code:
    random1 = rand() &#37;9;
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  3. #3
    Join Date
    Oct 2009
    Posts
    26

    Re: compiling errors

    random1 = rand() 9;
    random2 = rand() 9;
    random1 = rand() 89 + 10;
    random2 = rand() 89 + 10;
    all these areas have error. please insert some arthamatic operation after rand() function and constant number.

  4. #4
    Join Date
    Apr 2005
    Posts
    107

    Re: compiling errors

    Start Here... To get some ideas how rand() actually works and how to use it...
    http://www.eternallyconfuzzled.com/a..._art_rand.aspx

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

Featured