Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 program help
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Geminias




PostPosted: Tue Oct 04, 2005 8:13 pm   Post subject: program help

hey, i'm a noob having some trouble with this program. Won't compile and i don't understand the compiler's hints. If anyone could give me some pointers on what is wrong please do so.



Syntax = C++
code:
#include <iostream>
#include <windows.h>
#include <math.h>
using namespace std;

float quadrant1y (float s, float t)
{
      float yaxis;

      yaxis = sin*s*t;
     
      return (yaxis);
}
 
float quadrant1x (float x, float y)
{
      float xaxis;

     
      xaxis = cos*x*y;

     
      return (xaxis);
}

int main ()
{

cout << "This program will resolve vectors into their components.\n";
cout << "Just follow the instructions. /n";
sleep (1000);
cout << "Enter the displacement in km";
cin >> displacement;
cout << "input the angle.";
cin >> angle;

if (0 <= angle <=90)
{
   quadrant1x (angle, displacement)
   quadrant1y (angle, displacement)
}

   cout << "the x axis is: " << quadrant1x << endl;
   cout << "the y axis is: " << quadrant2y << endl;
   
     return 0;
}


Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Tue Oct 04, 2005 8:27 pm   Post subject: (No subject)

Well, there are many things wrong with your code, but one stands out in particular. "sin" is a function. Why aren't you calling it as such?

code:
sin*s*t
Geminias




PostPosted: Tue Oct 04, 2005 8:28 pm   Post subject: (No subject)

i thought it was more like an operand Rolling Eyes
wtd




PostPosted: Tue Oct 04, 2005 8:30 pm   Post subject: (No subject)

Also, where is "displacement" declared?

code:
cin >> displacement;
md




PostPosted: Tue Oct 04, 2005 8:42 pm   Post subject: (No subject)

I was going to write a nice big thing here but sicne I seem to have been beaten to it while writing it I'll just post some fixed code so you can see it working:

c++:


#include <iostream>
#include <windows.h>
#include <math.h>

float quadrant1y (float s, float t)
{
      return sin(s*t);
}
 
float quadrant1x (float x, float y)
{
      return cos(x*y);
}

int main ()
{

float displacement;
float angle;

cout << "This program will resolve vectors into their components.\n";
cout << "Just follow the instructions. /n";
sleep (1000);
cout << "Enter the displacement in km";
cin >> displacement;
cout << "input the angle.";
cin >> angle;

if (0 <= angle <=90)
{
   cout << "the x axis is: " << quadrant1x(angle, displacement) << endl;
   cout << "the y axis is: " << quadrant2y(angle, displacement) << endl;
}

return 0;
}

Geminias




PostPosted: Tue Oct 04, 2005 9:29 pm   Post subject: (No subject)

thanks guys. But one question.

you put "sin(s*t)"

is that the same as "sin(s) * (t)" ?

because it is not the same thing on a calculator.
wtd




PostPosted: Tue Oct 04, 2005 9:48 pm   Post subject: (No subject)

No.

You have the function name, then parentheses. Inside the parentheses are any argument(s) to the function.

In this case the argument is "s * t".
[Gandalf]




PostPosted: Tue Oct 04, 2005 10:26 pm   Post subject: (No subject)

Laughing Nice new sig, wtd

You were also missing some ';''s from the end of some lines, try to check that first if you get some errors (which should easily tell you that this is the problem).
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: