#include #include #define MIN 1 #define MAX 30 struct Circle { float xCoord; float yCoord; float radius; }; /* prototypes */ float getRandomNumber (int min, int max); void printByValue(struct Circle cirobj); void setValue(float *target, float newValue); void printByReference(struct Circle *cirobj); int main(void) { /* Declare a struct circle and name it circle0bject */ struct Circle circleObject; /* Fill circleObject's members with random numbers */ circleobject.xCoord = getRandomNumber(MIN, MAX); circleobject.yCoord = getRandomNumber (MIN, MAX); circleobject.radius = getRandomNumber (MIN, MAX); /* Printing values of the circle by calling function print by value */ printByValue(circleObject); /* update values of circle one by one */ setValue (&circleObject.xCoord, getRandomNumber(MIN, MAX)); setValue (&circleObject.yCoord, getRandomNumber(MIN, MAX)); setvalue (&circleObject.radius, getRandomNumber(MIN, MAX));
#include #include #define MIN 1 #define MAX 30 struct Circle { float xCoord; float yCoord; float radius; }; /* prototypes */ float getRandomNumber (int min, int max); void printByValue(struct Circle cirobj); void setValue(float *target, float newValue); void printByReference(struct Circle *cirobj); int main(void) { /* Declare a struct circle and name it circle0bject */ struct Circle circleObject; /* Fill circleObject's members with random numbers */ circleobject.xCoord = getRandomNumber(MIN, MAX); circleobject.yCoord = getRandomNumber (MIN, MAX); circleobject.radius = getRandomNumber (MIN, MAX); /* Printing values of the circle by calling function print by value */ printByValue(circleObject); /* update values of circle one by one */ setValue (&circleObject.xCoord, getRandomNumber(MIN, MAX)); setValue (&circleObject.yCoord, getRandomNumber(MIN, MAX)); setvalue (&circleObject.radius, getRandomNumber(MIN, MAX));
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question

Transcribed Image Text:/* Printing values after update by calling function print by reference */
printByReference(&circleObject);
}
Task1.1: define the function
float getRandomNumber(int min, int max);
that returns a random number generated within the range min and max.
Task1.2: define the function
void printByValue(struct Circle cirobj);
that prints on the screen values of circle (xCoord, yCoord, and radius).
Task1.3: define the function
void setValue(float *target, float newValue);
that updates the given variable var with the new value. Use this to update the value of circle
object in the activity. For example, call it to update values of xCoord, yCoord, and radius.
Task1.4: define the function
void printByReference (struct Circle *cirobj);
that prints on the screen the values of circle object after using the function in Task1.3 above
but with call by reference (pointer of circle).

Transcribed Image Text:Activity 1
This program firstly initializes an object of struct Cirele with values and then updates those
using pointers. The program uses structure notation once and pointer notation another
afterwards.
#include<stdio.h>
#include<stdlib.>
#define MIN 1
#define MAX 30
struct Circle {
float xCoord;
float yCoord;
float radius;
};
/* prototypes */
float getRandomNumber (int min, int max);
void printByValue(struct Circle cirobj);
void setValue(float *target, float newValue);
void printByReference(struct Circle *cirObj);
int main(void) {
/* Declare a struct circle and name it circleobject */
struct Circle circleObject;
/* Fill circleObject's members with random numbers */
circleobject.xCoord = getRandomNumber(MIN, MAX);
circleobject.yCoord = getRandomNumber (MIN, MAX);
circleobject.radius = getRandomNumber (MIN, MAX);
/* Printing values of the circle by calling function print by value */
printByValue(circleobject);
/* update values of circle one by one */
setValue (&circleobject.xCoord, getRandomNumber(MIN, MAX));
setValue (&circleobject.yCoord, getRandomNumber (MIN, MAX));
setvalue (&circleobject.radius, getRandomNumber(MIN, MAX));
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 2 images

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY