Thread: Can't read int

  1. #1
    Registered User
    Join Date
    Dec 2019
    Posts
    46

    Can't read int

    Code:
    #include <iostream>#include <cmath>
    using namespace std;
    const double g=9.8
    
    
    int main()
    {
    
    
        cout<<"Enter two Numbers"<<endl;
        double v1, v2;
       cin>>v1>>v2;
    cout<<"The sun of " << v1<<" and "<< v2<<" is " << pow (v1,v2)/g*sin(theta)<< endl;
    
    
    
    
    
    
        return 0;
    }
    ||=== Build file: "no target" in "no project" (compiler: unknown) ===|
    distance.cpp|6|error: expected ',' or ';' before 'int'|
    ||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,532
    Check for missing semicolons in your code.

    Also with most IDEs you should be using a project to compile your code.

  3. #3
    Informer -Adrian's Avatar
    Join Date
    Jan 2013
    Posts
    830
    What Jim said, it's a missing semicolon. And format your code properly, don't post such a mess here again if you want help!

  4. #4
    Registered User
    Join Date
    Dec 2019
    Posts
    46
    Quote Originally Posted by jimblumberg View Post
    Check for missing semicolons in your code.

    Also with most IDEs you should be using a project to compile your code.
    T'was not a semicolon me lord!

  5. #5
    Registered User
    Join Date
    Feb 2019
    Posts
    671
    Geez, I don't know, but maybe the error message says everything you need to know...

    distance.cpp|6|error: expected ',' or ';' before 'int'

  6. #6
    Registered User
    Join Date
    Dec 2019
    Posts
    46
    Quote Originally Posted by flp1969 View Post
    Geez, I don't know, but maybe the error message says everything you need to know...

    distance.cpp|6|error: expected ',' or ';' before 'int'
    Ya 'n now it say it due to sin not being defined.

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,726
    I would have thought it more likely to report that theta wasn't declared.
    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

  8. #8
    Informer -Adrian's Avatar
    Join Date
    Jan 2013
    Posts
    830
    Quote Originally Posted by solidusMGS View Post
    T'was not a semicolon me lord!
    Line #3

  9. #9
    Registered User
    Join Date
    Dec 2019
    Posts
    46
    Quote Originally Posted by -Adrian View Post
    Line #3
    You poppin' cough medicine or something? I fixed line 3, still wasn't it yo!

  10. #10
    Registered User
    Join Date
    Feb 2019
    Posts
    671
    Quote Originally Posted by solidusMGS View Post
    You poppin' cough medicine or something? I fixed line 3, still wasn't it yo!
    You need to learn how to read:

    Code:
    #include <iostream>
    #include <cmath>
    
    using namespace std;
    
    const double g = 9.8;
    
    int main()
    {
      cout << "Enter two Numbers" << endl;
    
      double v1, v2;
    
      cin >> v1 >> v2;
    
      cout << "The sun of " << v1 << 
              " and " << v2 << 
              " is " << pow( v1, v2 ) / g * sin( theta ) << 
              endl;
    
      return 0;
    }
    Code:
    $ c++ -o test test.cc
    test.cc: In function ‘int main()’:
    test.cc:18:46: error: ‘theta’ was not declared in this scope
               " is " << pow( v1, v2 ) / g * sin( theta ) <<
                                                  ^~~~~

  11. #11
    Registered User
    Join Date
    Dec 2019
    Posts
    46
    Quote Originally Posted by flp1969 View Post
    You need to learn how to read:

    Code:
    #include <iostream>
    #include <cmath>
    
    using namespace std;
    
    const double g = 9.8;
    
    int main()
    {
      cout << "Enter two Numbers" << endl;
    
      double v1, v2;
    
      cin >> v1 >> v2;
    
      cout << "The sun of " << v1 << 
              " and " << v2 << 
              " is " << pow( v1, v2 ) / g * sin( theta ) << 
              endl;
    
      return 0;
    }
    Code:
    $ c++ -o test test.cc
    test.cc: In function ‘int main()’:
    test.cc:18:46: error: ‘theta’ was not declared in this scope
               " is " << pow( v1, v2 ) / g * sin( theta ) <<
                                                  ^~~~~
    What's 'read'? Is that like a definition c++ uses?

  12. #12
    Registered User
    Join Date
    May 2009
    Posts
    3,824
    Quote Originally Posted by solidusMGS View Post
    What's 'read'? Is that like a definition c++ uses?
    They mean you should read the error message instead of ignoring them!

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 10-28-2015, 02:07 PM
  2. Replies: 2
    Last Post: 12-07-2014, 07:01 AM
  3. Is possible read text form keyboard using read() function?
    By Vanhapolle in forum C Programming
    Replies: 3
    Last Post: 12-08-2013, 11:51 PM
  4. Replies: 7
    Last Post: 12-07-2012, 10:44 PM
  5. blocked on read/recv / how to read/send proper buffers
    By fudgecode in forum Networking/Device Communication
    Replies: 1
    Last Post: 11-02-2010, 11:42 PM

Tags for this Thread