Thread: Can't read int

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2019
    Posts
    99

    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,632
    Check for missing semicolons in your code.

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

  3. #3
    Registered User
    Join Date
    Dec 2019
    Posts
    99
    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!

  4. #4
    Guest
    Guest
    Quote Originally Posted by solidusMGS View Post
    T'was not a semicolon me lord!
    Line #3

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

  6. #6
    Registered User
    Join Date
    Feb 2019
    Posts
    1,078
    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 ) <<
                                                  ^~~~~

  7. #7
    Guest
    Guest
    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!

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

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

  9. #9
    Registered User
    Join Date
    Dec 2019
    Posts
    99
    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.

  10. #10
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    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

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