// C code
#include <stdio.h>
#include <stdlib.h>
#define PI 3.14
typedef struct circle
{
double x;
double y;
double radius;
} Circle;
double rand_float(double a,double b)
{
return ((double)rand()/RAND_MAX)*(b-a)+a;
}
double getArea(double r)
{
return PI * r * r;
}
void main()
{
Circle *arr = malloc(sizeof(Circle)*50); //create array
int i, maxIndex;
double maxArea;
for (i=0; i<50; i++)
{ //poulate array
arr[i].x = rand_float(100,900);
arr[i].y = rand_float(100,900);
arr[i].radius = rand_float(0,100);
}
maxArea = getArea(arr[0].radius);
maxIndex = 0;
for (i=1; i<50; i++) //find max area among all circle
if ( getArea(arr[i].radius) > maxArea)
{
maxArea = getArea(arr[i].radius);
maxIndex = i;
}
printf("Circle with largest area (%lf) \nhas center (%lf,%lf) and
radius %lf\n", maxArea, arr[maxIndex].x, arr[maxIndex].y,
arr[maxIndex].radius);
free(arr); //prevent memory leak
}
/*
sample output:
Circle with largest area (29386.402844)
has center (686.123529,625.250922) and radius 96.740514
*/
Please help with C Thanks Declare a structure to represent a circle. Each circle stores information...
I
need help with C, please don't copy other answers!!
Thanks
Declare a structure to represent a circle. Each circle stores information about the center and the radius. Center is represents with x and y coordinates. Both center and radius uses doubles. Allocate an array of 502 circle pointers and dynamically allocated memory to store a circle pointed by each array entry. Randomly generate circles using the following function. double rand_ float (double a, double b) {return ((double) rand()/RAND_MAX) *...
please answer the second part first part answered. the answer to the first part is at the bottom bring the rest of the place HAVE TO BE SOLVED WİTH C PROGRAMMİNG A programming task is given in below (i.e., you are supposed to write a single program involving all 5 tasks in below). You should write a C program and upload your c/cpp file . Students are allowed to use MAK104E course (powerpoint) slights. 1) Three geometric entities (a circle,...
Using separate files, write the definition for a class called Point and a class called Circle. The class point has the data members x (double) and y (double) for the x and y coordinates. The class has the following member functions: a) void set_x(double) to set the x data member b) void set_y(double) to set the y data member c) double get_x() to return the the x data member d) double get_y() to return the the y data member e)...
Please use C++. Write a class named Circle that has a double data member named radius and a static double data member named maxRadius. It should have a default constructor that initializes the radius to 1.0. It should have a constructor that takes a double and uses it to initialize the radius. It should have a method called calcArea that returns the area of the Circle (use 3.14159 for pi). It should have a static set method for the maxRadius....
Please write below code in C++ using Visual
Studio.
Write program that uses a class template to create a set of items. The program should: 1. add items to the set (there shouldn't be any duplicates) • Example: if your codes is adding three integers, 10, 5, 10, then your program will add only two values 10 and 5 • Hint: Use vectors and vector functions to store the set of items 2. Get the number of items in the...
C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) Last Name (char[]) Age (int) Height in Inches (double) Weight in Pounds (double) You will use pass-by-reference to modify the values of the arguments passed in from the main(). Remember that arrays require no special notation, as they are passed by reference automatically, but the other...
Please help, provide source code in c++(photos attached)
develop a class called Student with the following protected
data:
name (string), id (string), units (int), gpa (double).
Public functions include:
default constructor, copy constructor, overloaded = operator,
destructor, read() to read data into it, print() to print its data,
get_name() which returns name and get_gpa() which returns the
gpa.
Derive a class called StuWorker (for student worker) from
Student with the following added data:
hours (int for hours assigned per week),...