Dear Student,
Here is the program..
NOTE: Please note that the following program has been tested on ubuntu 14.04 system and compiled under gcc compiler.
-------------------------------------------------------------------------------------------------------------------------------------
program...
------------------------------------------------------------------------------------------------------------------------------------
//Header files DEclaration
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
//Structure Declarartion
struct Circle
{
//structure member declarartion
double x; //x coordinate
double y; //y coordinate
double r; //radius
};
//function Prototype Declaration
double rand_float(double a, double b);
//starting of main function
int main()
{
//Varibale Data Type declaration
int i;
double Area[100];
double PI = 3.14, x, y, max, r;
struct Circle *C;
//Memory allocation for 50 array
C = (double*)malloc(sizeof(struct Circle) * 50);
//Call to rand_float function 50 times to obtain the value of r, x, y
for(i=1;i<=50;i++)
{
C[i].x = rand_float(100, 900);
C[i].y = rand_float(100, 900);
C[i].r = rand_float(0, 100);
//Calculation of Area;
Area[i] = PI* pow(C[i].r, 2);
}
//Display all dimensions for 50 circles and the resultant area
for(i=1;i<=50;i++)
{
printf("CIrcle %d, Center: x = %lf, y = %lf, radius = %lf, Area = %lf\n",i, C[i].x, C[i].y, C[i].r, Area[i]);
}
//finding Maximum Area;
for(i = 1; i<=50;i++)
{
if(Area[1] > Area[i])
{
max = Area[i];
x = C[i].x;
y = C[i].y;
r = C[i].r;
}
}
printf("\n");
//Display Max area
printf("Circle withe largest area (%lf) has center (%lf, %lf) and radius %lf\n",max, x, y, r);
printf("\n");
free(C);
return 0;
}
//function defination to return the x, y, r;
double rand_float(double a, double b)
{
return ((double)rand()/RAND_MAX) * (b-a) + a;
}
---------------------------------------------------------------------------------------------------------------------------------------
Here i have attached the output of the program as a screen shot...
Output:
-------------------------------------------------------------------------------------------------------------------------------------


----------------------------------------------------------------------------------------------------------------------------------------------
To check the memory leak we use the valgrind command.
below command i have used to check the memory leak in my case..
valgrind --tool=memcheck ./a.out (here ./a.out is the executable file)
here i have attached the output of the valgrind command. In the last screen shot you can see that no memory leak found.
----------------------------------------------------------------------------------------------------------------------------------



------------------------------------------------------------------------------------------------------------------------------------------
Kindly Check and Verify Thanks...!!!
I need help with C, please don't copy other answers!! Thanks Declare a structure to represent...
Please help with C
Thanks
Declare a structure to represent a circle. Each circle stores information about the center and the radius. Center is represented with x and y coordinates. Both center and radius uses doubles. Allocate an array of 50 circle pointers and dynamically allocate memory to store a circle pointed by cash array eatery. Randomly generate circles using the following function. double rand_float (double a.double b) {return ((double)rand()/RAND_MAX)=(b-a)+a:} We want all the circles to fit an area of...
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,...
Please need help, programming in C
- Part A You will need to create a struct called Team that contains a string buffer for the team name. After you've defined 8 teams, you will place pointers to all 8 into an array called leaguel], defined the following way: Team leaguel8]. This must be an aray of pointers to teams, not an array of Teams Write a function called game) that takes pointers to two teams, then randomly and numerically determines...
c++ Please help! i keep getting an error message. I think my
main problem is not understanding the circle calculations function
and how both the area and the circumference is returned from the
function. I know & needs to be used, but I am unsure how to use
it.
Copy the following code and run it. You should break it into the following 3 functions getValidinput - which asks the user to enter the radius and then make sure that...
Write a C++ program for the instructions below. Please
read the instructions carefully and make sure they are followed
correctly.
please put comment with code! and please do not just
copy other solutions.
Instructions 1. Read instructions carefully! 2. Use C++ syntax only, C syntax will not be accepted. 3. Always use braces to define blocks. 4. Indent all lines within a block. Each block requires one more tab. 5. Organize your code well with proper formatting and a single...
Hello I need help with this program. Should programmed in C!
Program 2: Sorting with Pointers Sometimes we're given an array of data that we need to be able to view in sorted order while leaving the original order unchanged. In such cases we could sort the data set, but then we would lose the information contained in the original order. We need a better solution. One solution might be to create a duplicate of the data set, perhaps make...
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...
I have updated my previously posted C++ question to ensure that I have included all of the necessary documentation in order to complete Part 2 - Bank Account of the assigned lab in its entirety. Please note that the lab below is somewhat lengthy, and I do not expect you to answer each question! If coding the full lab is too much to ask, please focus soley on Part 2 of the lab, titled Bank Account and the subsections that...
I need to implement a program that requests a x,y point and the radius of a circle. then it figures out the area and circumference using an overloaded operation. The full instructions, what I have and the errors I have are below. A point in the x-y plane is represented by its x-coordinate and y-coordinate. Design a class, pointType, that can store and process a point in the x-y plane. You should then perform operations on the point, such as...
I NEED ALL QUESTIONS OR ELSE THUMBS DOWN! C++ Implement a structure Employee. An employee has a name (a char *) and a salary (a double). Write a default constructor, a constructor with two parameters (name and salary), and methods char* getName() double getSalary() to return the name and salary. Write a small global function TestEmployee() to test your structure. Creating a new employee. Please type the name: Larry Bird Please specify the salary: 200000 New employee has been created....