jorhez
asked on
Program won't run.
The program is not difficult, but when I use pointers it won't run.The program is as follows:
/* This program asks for the circumference and calculates the circle's radius and its area*/
/* This program asks for the circumference and calculates the circle's radius
and its area*/
#include<iostream.h>
#include<math.h>
#define PI 3.14159
void main(void)
{
double circum,area,radio;
void radius(double,double *);
void areas(double,double *);
cout<<"Entre la circumferencia del circulo, para computar su area\n";
cin>>circum;
radio=radius(circum,&radio );
area=areas(radio,&area);
cout<<"El area de el circulo es "<<area;
}
void radius(double cicum,double *radio)
{
*radio=circum/(2.000000*PI );
}
void areas(double radio,double*area)
{
double area;
*area=PI*pow(radio,2.00000 0);
}
/* This program asks for the circumference and calculates the circle's radius and its area*/
/* This program asks for the circumference and calculates the circle's radius
and its area*/
#include<iostream.h>
#include<math.h>
#define PI 3.14159
void main(void)
{
double circum,area,radio;
void radius(double,double *);
void areas(double,double *);
cout<<"Entre la circumferencia del circulo, para computar su area\n";
cin>>circum;
radio=radius(circum,&radio
area=areas(radio,&area);
cout<<"El area de el circulo es "<<area;
}
void radius(double cicum,double *radio)
{
*radio=circum/(2.000000*PI
}
void areas(double radio,double*area)
{
double area;
*area=PI*pow(radio,2.00000
}
ASKER
Edited text of question
ASKER
I had sent a similar message, but I forgot to include some changes I had done on the program. I want to use pointers on this one in order to understand them, although I know their not essntial.
ASKER
I had sent a similar message, but I forgot to include some changes I had done on the program. I want to use pointers on this one in order to understand them, although I know their not essential.
ASKER
I had sent a similar message, but I forgot to include some changes I had done on the program. I want to use pointers on this one in order to understand them, although I know their not essential for the program to run correctly.
First of all your functions are declared as returning void - it will be an error truing to capture the return value. All you need is to change these two lines:
radio=radius(circum,&radio );
area=areas(radio,&area);
Change them to:
radius(circum,&radio);
area=areas(radio,&area);
Thanks
pagladasu
radio=radius(circum,&radio
area=areas(radio,&area);
Change them to:
radius(circum,&radio);
area=areas(radio,&area);
Thanks
pagladasu
Pagladasu - See
https://www.experts-exchange.com/topics/comp/lang/cplusplus/Q.10108117
He's already accepted my answer
https://www.experts-exchange.com/topics/comp/lang/cplusplus/Q.10108117
He's already accepted my answer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
your pointers need the matching &address.
eg.
void radius(double, double *)
void main()
{
double circ;
double radio;
Radius(double, &double) ...there I think that's it.
but you could do this
radius(double, double)
and the proto will be void radius(double, double &);
}
eg.
void radius(double, double *)
void main()
{
double circ;
double radio;
Radius(double, &double) ...there I think that's it.
but you could do this
radius(double, double)
and the proto will be void radius(double, double &);
}
Sorry Answer2000. Did not notice that that you had already answered it and that the answer had been accepted.
jorhez, delete this question and you will be refunded the points. Once someone answers the question cannot be deleted.