Author |
Message |
Geminias
|
Posted: 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;
}
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
wtd
|
Posted: 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?
|
|
|
|
|
![](images/spacer.gif) |
Geminias
|
Posted: Tue Oct 04, 2005 8:28 pm Post subject: (No subject) |
|
|
i thought it was more like an operand ![Rolling Eyes Rolling Eyes](http://compsci.ca/v3/images/smiles/icon_rolleyes.gif) |
|
|
|
|
![](images/spacer.gif) |
wtd
|
Posted: Tue Oct 04, 2005 8:30 pm Post subject: (No subject) |
|
|
Also, where is "displacement" declared?
code: | cin >> displacement; |
|
|
|
|
|
![](images/spacer.gif) |
md
![](http://compsci.ca/v3/uploads/user_avatars/1849317514ed6c4399768d.png)
|
Posted: 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;
}
|
|
|
|
|
|
![](images/spacer.gif) |
Geminias
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
wtd
|
Posted: 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". |
|
|
|
|
![](images/spacer.gif) |
[Gandalf]
![](http://compsci.ca/v3/uploads/user_avatars/189297994e4c716fec7f1.png)
|
Posted: Tue Oct 04, 2005 10:26 pm Post subject: (No subject) |
|
|
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). |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|