Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Program won't run.

Posted on 1998-12-13
10
Medium Priority
?
178 Views
Last Modified: 2010-04-02
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.000000);
 }
0
Comment
Question by:jorhez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1180087
NOTE TO EXPERTS  THIS IS A DUPLICATE QUESTION  Unless Jorhes indicates otherwise, please answer on other question  

jorhez, delete this question and you will be refunded the points.  Once someone answers the question cannot be deleted.
0
 

Author Comment

by:jorhez
ID: 1180088
Edited text of question
0
 

Author Comment

by:jorhez
ID: 1180089
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.


0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jorhez
ID: 1180090
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.


0
 

Author Comment

by:jorhez
ID: 1180091
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.


0
 
LVL 4

Expert Comment

by:pagladasu
ID: 1180092
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
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1180093
Pagladasu - See
http://www.experts-exchange.com/topics/comp/lang/cplusplus/Q.10108117

He's already accepted my answer
0
 
LVL 1

Accepted Solution

by:
billyh earned 100 total points
ID: 1180094
Here is you answer.

#include<iostream.h>
#include<math.h>
#define PI 3.14159

// Declare these variables as globals. These is a bad programming style.
double circum,area,radio;

void main(void)
{
      void radius(double,double *);
      void areas(double,double *);
      
      cout<<"Entre la circumferencia del circulo, para computar su area\n";
      cin>>circum;
      radius(circum,&radio);
      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)
{
      *(area) = PI * pow(::radio,2.000000);
}

0
 
LVL 1

Expert Comment

by:The_Brain
ID: 1180095
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 &);

}
0
 
LVL 4

Expert Comment

by:pagladasu
ID: 1180096
Sorry Answer2000. Did not notice that that you had already answered it and that the answer had been accepted.

0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question