Ummm, what input do you have that is an angle?
sorry forbeing so dumb, what could be wrong with my cin? this is the program from hell.
edit:
is this why im getting this warning?
polar.cpp:15:12: warning: expression result unused [-Wunused-value]
cin >> r, angle;
(cin >> r), (angle);
cin >> r;
angle;
now my output is correct, except instead of 3.19531, 1.42829 i get the reverse.
is that just because i opted to output x before y? or is it evidence of a huge mess up? lol
lol my heads about to explode. i think its finally done though, so im turning off the homework brain. been doing assignments since 10am. it is now 10pm. ouch. anyway so i think we're set here.. are we not?? did i finally accomplish the impossible?Shannon,
When you find yourself fluster and confused, like now, it's best to tale a break of at least 15 minutes, do something that doesn't require much thinking, and come back to the problem.
Banging yoir head against the wall for hours, noting it hurts and banging your head against the wall some more is kind crazy.
Assuming that is the answer the prof. expected the angle is 20 radians, not 20 degrees. That seems a bit wacky as it is 6 full rotations and 65.9 degrees left over.
B
You want to split that into a .cpp and a header file. The header files contain the function and method definitions:Code:#include <iostream> using namespace std; #include <cmath> void polar (double &, double &, double, double); int main () { double x; double y; double r; double angle; cout << "Enter two numbers for polar coordinates: "; cin >> r, angle; polar (x, y, r, angle); cout << "The corresponding rectangular coordinates are (" << x << ", " << y << ")" << endl; return 0; } void polar (double & x, double & y, double r, double angle) { x = r * cos(angle); y = r * sin(angle); }
thanks for your patience 😀😀😀
#include <iostream>
#include <cmath>
[url=http://www.cplusplus.com/doc/tutorial%20%20/preprocessor/]#define[/url] DEG2RAD(DEG) ((DEG)*((3.14159265358979323846)/(180.0)))
void polar2rectangular(double &, double &, double, double);
#include "pol2rect.h"
void polar2rectangular(double & x, double & y, double r, double angle)
{
x = r * cos(angle);
y = r * sin(angle);
}
int main ()
{
double x, y, r, angle;
std::cout << "Enter the radius: ";
std::cin >> r;
std::cout << "Enter the the angle: ";
std::cin >> angle;
polar2rectangular(x, y, r, DEG2RAD(angle));
std::cout << "The corresponding rectangular coordinates are (x=" << x << ", y=" << y << ")" << std::endl;
return 0;
}
g++ -Wall pol2rec.cpp -o pol2rec
Hey guyssss.. so my exam is this coming thursday, and the major topics (that are actually confusing me) that are on it are arrays and classes.. does anyone know of a concise, easy to understand website that I could refer to in my studying?
It's been a whole month since your last post so I'm not really sure where you're at and what you've covered since then.
Perhaps an update ...
Well, congratulations!
We see so many students pass thru here never to be heard from again. In your case I see you've checked back since your last post so thought I'd ask a couple of questions.
What are you going to school for?
Have you enjoyed any of your programming experience?
Do you still fear tackling problem solving?
Good luck.