Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8340517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:12:01+00:00 2026-06-09T05:12:01+00:00

I need some help with the following problem which is to work out the

  • 0

I need some help with the following problem which is to work out the areas of each circle within an array using the getArea() method. How do I go about accessing an array and then working out the area of the circle using Circle::getArea() member function.

Main.cpp file

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

#include "Circle.h"
#include "Random.h"

int main()
{
    // Array 1, below section is to populate the array with random 
    // radius number within lower and upper range
    int CircleArrayOne [5];
    const int NUM = 5;

    srand(time(NULL));

    for(int x = 0; x < NUM; ++x)
    {
        CircleArrayOne[x] = Random::random(1, 40); // assumed 0 and 40 as the bounds
    }

    // output the radius of each circle
    cout << "Below is the radius each of the five circles in the second array. " << endl;

    // below is to output the radius in the array
    for(int i = 0; i < NUM; ++i) 
    {
        cout << CircleArrayOne[i] << endl;
    }

    // Here I want to access the array to work out the area using 
    // float Circl::getArea()

    system("PAUSE");
    return 0;
}

float Circle::getArea()
{
    double PI = 3.14;
    return (PI * (Radius*Radius));
}

float Circle::getRadius()
{
    return Radius;
}

int Random::random(int lower, int upper)
{
    int range = upper - lower + 1;
    return (rand() % range + lower);
}

Circle.h file

#pragma once
#include <string>

class Circle 
{
private:
    float Radius;

public:
    Circle(); // initialised radius to 0
    Circle(float r); // accepts an argument and assign its value to the radius attribute
    void setRadius(float r); // sets radius to a value provided by its radius parameter (r)
    float getRadius(); // returns the radius of a circle
    float getArea(); // calculates and returns the areas of its circle
};

Thanks.
Much help is much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:12:02+00:00Added an answer on June 9, 2026 at 5:12 am

    So far you just have the random radius for circles but do not have Circle objects. So, first create circle objects.

    Circle obj[5];   // Create 5 objects default constructed.
    

    Now set each object radius using setRadius and call area on each object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help extracting the following bits of information using regular expressions. Here
I am new to jQuery and need some help with the following problem. I
I am venturing babysteps in ggplots and need some help with the following problem!
I need some help in picking the 'right' solution for the following 'problem'. I
i need some help with this problem. I have a binary tree stucture which
I need some help solving some compile errors. I was following a tutorial (at
I need some help writing a regex. I have the following strings, xxx.yyy.wwwwwaaa_IN_123 xxx.rrrttttt_IN_12355
I need some help with something... say I have the following form... <form name=
I've written the following IComparer but I need some help. I'm trying to sort
I am new to django and need some quick help. How will the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.