just Admit in a university and new in C++

i just wanted to know how to do area for several circle
How to modify the code below to do the area of circle??

here's the code:

//Calculate area of a circle
#include <cstdlib>
#include <iostream>

using namespace std;
// function main begins program execution
int main(int argc, char *argv[])
    int radius; //Radius to be input by the user
    int pi; //pi to be input by the user
    int area; //variable in which area will be stored
    printf("Enter the Radius of the Circle\n"); //prompt
    scanf("%d", &radius); //read  an integer
    printf("Enter the Pi\n"); //prompt
    scanf("%d", &pi); //read an integer
    area=(pi*radius*radius); //assign total to area
    printf("Area of Circle is %d\n", area); //print area
    return 0; //indicate that program ended successfully
    return EXIT_SUCCESS;
} //end of function

thanks in advance

6 Years
Discussion Span
Last Post by Tellalca

You need to supply more information and understand the problem. Are you looking for a sum of areas of multiple circles, Or a printout of the different circles. Also, are these circles independent or overlapping. You need to understand the problem before you can achieve a solution. How would you do it in real life first?


Here's the question:
modify the above exercise (Exercise 3) to calculate the area of several circles.

THE exercise 3 is the code i pasted above.
any help


Maybe it will be better to declare pi, radius and area as double or float.

If you want to calculate areas of more circles, you can try a loop and then add the areas to the sum.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.