Click here to Skip to main content
16,004,778 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
What does it means? and where did I make a mistake?

What I have tried:

C++
#include<iostream>
#include<cmath>
using namespace std;

void polar_to_rect(double&, double&, double , double );

int main()                                           
{               
    char ch;                                         
    double mag, angle, x, y;
    
    
    cout<<"           This program converts  a polar vector to a rectangular vector.."<<endl<<endl;
    
    while (ch != 'n')
    {
          cout<<"Enter the value of mag: ";      
          cin>>mag;
          cout<<"Enter the value of angle: ";
          cin>>angle;
          
          
          polar_to_rect(mag,angle, x, y);
          cout<<"                            >>x = "<<x<<endl;
          cout<<"                            >>y= "<<y<<endl<<endl;
          cout<<"Another calculation? (y/n)... ";
          cin>>ch;
    }
    
    
    return 0;                                      
}  

void polar_to_rec(double _mag, double angle, double &x, double &y)
{     
      x = _mag * cos(angle);
	  y = _mag * sin(angle);
	  
      return;
}</cmath></iostream>
Posted
Updated 21-Feb-16 13:55pm
v2

try removing the 'return;' at the end of the polar_to_rec routine
 
Share this answer
 
First of all, prototype and function must mach.
C++
void polar_to_rect(double&, double&, double , double );

C++
void polar_to_rec(double _mag, double angle, double &x, double &y)

x and y in the function are pointers to x and y in main
Make sure that the compiler knows what is going on in the function and store the calculus in the right place.

You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.

The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html[^]
https://www.jetbrains.com/idea/help/debugging-your-first-java-application.html[^]
 
Share this answer
 
Comments
Garth J Lancaster 21-Feb-16 21:29pm    
Im glad your eyes are better than mine ! :-)
Patrice T 22-Feb-16 1:58am    
Thank you :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900