Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question
[画像:/* 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). ]
expand button
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).
[画像: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)); ]
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Similar questions
    Recommended textbooks for you
    Text book image
    Computer Networking: A Top-Down Approach (7th Edi...
    Computer Engineering
    ISBN:9780133594140
    Author:James Kurose, Keith Ross
    Publisher:PEARSON
    Text book image
    Computer Organization and Design MIPS Edition, Fi...
    Computer Engineering
    ISBN:9780124077263
    Author:David A. Patterson, John L. Hennessy
    Publisher:Elsevier Science
    Text book image
    Network+ Guide to Networks (MindTap Course List)
    Computer Engineering
    ISBN:9781337569330
    Author:Jill West, Tamara Dean, Jean Andrews
    Publisher:Cengage Learning
    Text book image
    Concepts of Database Management
    Computer Engineering
    ISBN:9781337093422
    Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
    Publisher:Cengage Learning
    Text book image
    Prelude to Programming
    Computer Engineering
    ISBN:9780133750423
    Author:VENIT, Stewart
    Publisher:Pearson Education
    Text book image
    Sc Business Data Communications and Networking, T...
    Computer Engineering
    ISBN:9781119368830
    Author:FITZGERALD
    Publisher:WILEY