Thread: Attempted to do assignment, can't figure out where it is wrong.

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

    Attempted to do assignment, can't figure out where it is wrong.

    So this is my terrible code. I thought it appeared decent, but it won't times a number and then it won't divide that number.
    Code:
    
    #include<iostream>
    #include<cmath>
    using namespace std;
    const double g = 9.8;
    
    
    int main()
    
    
    {
    
    
    int v, g, theta, division, multiplication;
    
    
    cout<<"How far can he put the safety net?";
    
    
    cin>> g >> theta;
    
    
    division  = v/g;
    
    
    multiplication = division *sin(2*theta);
    
    
    cout<< v << "*"<< g<< "="<< multiplication<< "/"<< division;
    
    
    return 0;
    }
    Last edited by Salem; 02-01-2020 at 11:23 PM. Reason: excessive blank lines

  2. #2
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    945
    Quote Originally Posted by solidusMGS View Post
    Code:
    division  = v/g;
    What is the value of "v" at this line?

  3. #3
    Registered User
    Join Date
    Dec 2019
    Posts
    99
    Quote Originally Posted by christop View Post
    What is the value of "v" at this line?
    None. They enter a value for v and then the equation does the rest.

  4. #4
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    945
    Which line gets a value for v? Look closely.

  5. #5
    Registered User
    Join Date
    Dec 2019
    Posts
    99
    Is it 13?

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by solidusMGS View Post
    Is it 13?
    Where does it get set to a value?

    Hint: I see no where it gets set to a value!

    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: 6
    Last Post: 07-12-2013, 01:14 PM
  2. Simple Assignment, Can't Figure Out the Calculation
    By iamtazb in forum C Programming
    Replies: 7
    Last Post: 10-01-2012, 05:39 AM
  3. C Programming Assignment Help!! (Cant Figure Out My Errors) :(
    By irishfeeney92 in forum C Programming
    Replies: 19
    Last Post: 04-28-2011, 02:14 PM
  4. Can't figure out what is wrong with this
    By Surfndog in forum C++ Programming
    Replies: 3
    Last Post: 02-21-2006, 07:26 AM
  5. I cant figure out what is wrong with this
    By C++angel in forum C++ Programming
    Replies: 3
    Last Post: 02-20-2006, 10:57 PM

Tags for this Thread