SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 5 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 05 Jan 2018 My Price 10.00

Example: StructuresDirect in CodeBlocks

need answers for all the questions in the document

Homework #8 EEL 2880 – Structures Consider the example program in Illustration #1. 1. Run the program from Illustration 1 and include a copy of the console output. 2. Which lines form the prototype for a structure 3. What is the tag name of the structure 4. Which lines create instances of the structure, what are the structure names? 5. Which lines initialize the member elements of the structures? How? 6. Which line is the prototype for a function with structure parameters 7. Which lines are the function definition with structure parameters 8. How are the member elements of a named (direct instance) structure dereferenced (how are the values changed)? 9. How is the addition of two structures accomplished? 1. /* Example: StructuresDirect in CodeBlocks 2. structures as function arguments and return values 3. Direct instances using names */ 4. 5. #include 6. #include 7. 8. struct cplx { 9. double real; /* real part */ 10. double imag; /* imaginary part */ 11. }; 12. 13. struct cplx add(struct cplx a, struct cplx b); /* function prototype */ 14. 15. 16. int main(void) 17. { 18. struct cplx x, y, z; 19. 20. 21. x.real = 2.5; 22. x.imag = 5.0; 23. y.real = 3.2; 24. y.imag = -1.7; 25. 26. 27. z = add(x, y); 28. printf("Direct Instance z = %4.2f + %4.2f j\n", z.real, z.imag); 29. return 0; 30. } 31. 32. 33. struct cplx add(struct cplx a, struct cplx b) 34. { 35. struct cplx c = a; /* can initialise an auto struct variable */ 36. 37. c.real += b.real; 38. c.imag += b.imag; 39. return c; /* can return a struct value */ 40. } Illustration 1 In C-language, a structure object can be created using the malloc () function. See http://www.tutorialspoint.com/cprogramming/pdf/c_memory_management.pdf So Illustration 2 creates instances of the structures while the program is running without a name but with a pointer to the memory space set aside. 10. Run the program from Illustration 2 and include a copy of the console output. 11. Which lines create instances of the structure, what are the structure names? 12. What are the structure pointer names? 13. Which lines initialize the member elements of the structures? How? 14. Which line is the prototype for a function with structure pointer parameters 15. Which lines are the function definition with structure pointer parameters 16. How are the member elements of an unamed (indirect instance) structure dereferenced (how are the values changed)? 17. How is the addition of two structures accomplished? 18. Could a pointer be returned from the function? 1. /* Example: StructuresIndirect in CodeBlocks 2. structures as function arguments and return values 3. indirect instances using pointers */ 4. 5. #include 6. #include 7. 8. struct cplx { 9. double real; /* real part */ 10. double imag; /* imaginary part */ 11. }; 12. 13. struct cplx add(struct cplx* pa, struct cplx* pb); /* function prototype */ 14. 15. 16. int main(void) 17. { 18. struct cplx z; 19. 20. 21. struct cplx* px= malloc(sizeof(struct cplx)); 22. struct cplx* py= malloc(sizeof(struct cplx)); 23. 24. px->real = 2.5; 25. px->imag = 5.0; 26. py->real = 3.2; 27. py->imag = -1.7; 28. 29. 30. z = add(px, py); 31. printf("Indirect Instance z = %4.2f + %4.2f j\n", z.real, z.imag); 32. return 0; 33. } 34. 35. 36. struct cplx add(struct cplx* pa, struct cplx* pb) 37. { 38. struct cplx c = *pa; /* can initialise an auto struct variable */ 39. 40. c.real += pb->real; 41. c.imag += pb->imag; 42. return c; /* can return a struct value */ 43. } Illustration 2

Attachments:

Answers

(5)
Status NEW Posted 05 Jan 2018 09:01 AM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)