Solved

Program won't run.

Posted on 1998-12-13
5
181 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*/
#include<iostream.h>
#include<math.h>
#define PI 3.14159
void main(void)
{
double circum,area,radio;
void radius(double);
void areas(double);
cout<<"Entre la circumferencia del circulo, para computar su area\n";
cin>>circum;
radio=radius(circum);
area=areas(radio);
cout<<"El area de el circulo de circumferencia "<<circum<<"es "<<area;
}
void radius(double circum)
{
 double radio;
 radio=circum/(2.000000*PI);
 }
 void areas(radio)
 {
 double area;
 area=PI*pow(radio,2.000000);
 }
0
Comment
Question by:jorhez
  • 3
  • 2
5 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1180082
I don't see any problems there  But you said you are having problems with pointers.  I don't see any pointers anywhere.

Can you explain the problem a little more?
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 50 total points
ID: 1180083
It's not a pointer problem, it's that your not return values from your 2 functions correctly

C++ Language Question
     Title: "Program won't run."

     From: jorhez
                                                                                                                  Date: Sunday, December 13 1998 - 05:15PM PST
     Status: Waiting for answer
     Points: 50 Points (Easy)


     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*/
     #include<iostream.h>
     #include<math.h>
     #define PI 3.14159
     void main(void)
     {
     double circum,area,radio;
     double radius(double);
     double areas(double);
     cout<<"Entre la circumferencia del circulo, para computar su area\n";
     cin>>circum;
     radio=radius(circum);
     area=areas(radio);
     cout<<"El area de el circulo de circumferencia "<<circum<<"es "<<area;
     }
     double radius(double circum)
     {
      double radio;
      radio=circum/(2.000000*PI);
      return radio ;
      }
      double areas(radio)
      {
      double area;
      area=PI*pow(radio,2.000000);
      return area ;
      }
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1180084
Ooops...I meant to say

"It's not a pointer problem, it's that you're not returning values from your 2 functions correctly "

The corrections I made should be correct in the answer I made previously

BTW if you want to use pointers instead of return values from functions, here's an example I version of your program that does that

     #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;
          radius(circum,&radio);
          areas(radio,&area);
          cout<<"El area de el circulo de circumferencia "<<circum<<"es "<<area;
          }
          void radius(double circum, double * pradio)
          {
           double radio;
           radio=circum/(2.000000*PI);
           *pradio = radio ;;
           }
           void areas(radio, double * parea)
           {
           double area;
           area=PI*pow(radio,2.000000);
           *parea = area ;
           }
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1180085
Oops another error

1. in my 6:23PM program, change

void areas(radio)
to
void areas( double radio )

2. In my 6:47PM program, change

void areas(radio, double * parea)
to
void areas(double radio, double * parea)



0
 
LVL 22

Expert Comment

by:nietod
ID: 1180086
I can't believe I missed that.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now