Thread: Help with error message: syntaz error befor "namespace"

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    2

    Help with error message: syntaz error befor "namespace"

    I dont know why im getting this error message. Im using BloodShead Dev-C++

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main ()
    {
        int "one";
        int "two";
        int "three";
        
        cout << "Enter Your Score One: \n";
        cin >> one;
    
        cout << "Enter Your Score Two: \n";
        cin >> two;
    
        cout << "Enter Your Score Three: \n";
        cin >> three;
    
        adverage = one + two + three / 3 = yourAdvarge;
    
        cout << "Your Advarge: ";
    
        return 0;
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    These are wrong:
    Code:
    int "one";
    int "two";
    int "three";
    It looks like you want to define variables named one, two and three, so they should be:
    Code:
    int one;
    int two;
    int three;
    This is wrong because adverage and yourAdvarge are not declared, and because it looks like you are attempting to assign the value of yourAdvarge to an expression that should not be on the left hand side of an assignment:
    Code:
    adverage = one + two + three / 3 = yourAdvarge;
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Tweaking master Aslaville's Avatar
    Join Date
    Sep 2012
    Location
    Rogueport
    Posts
    528
    You also have to declare the variable 'adverage' and include parenthesis in the operation where ypu are getting the average.

  4. #4
    Registered User
    Join Date
    Oct 2012
    Posts
    2
    Thank you both for your help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. "is not a class or namespace name" error
    By blakeo_x in forum C++ Programming
    Replies: 13
    Last Post: 09-16-2011, 03:08 AM
  2. the operator "="error in class "String"
    By boyhailong in forum C++ Programming
    Replies: 9
    Last Post: 07-27-2011, 08:39 PM
  3. "Segment Violation" error, fopen("r+")
    By jiboso in forum C Programming
    Replies: 1
    Last Post: 03-10-2011, 09:57 AM
  4. "Expected undefined-id" Error Message
    By FlyingShoes12 in forum C++ Programming
    Replies: 2
    Last Post: 11-03-2009, 08:55 PM
  5. Replies: 2
    Last Post: 09-12-2006, 04:50 AM

Tags for this Thread