Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. /* Example: StructuresDirect in CodeBlocks 2. structures as function arguments and return values 3. Direct instances using names */ 4. 5. #include 6. #include

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. time_t rawtime = time(NULL);

20.

21.

22. x.real = 2.5;

23. x.imag = 5.0;

24. y.real = 3.2;

25. y.imag = -1.7;

26.

27.

28. z = add(x, y);

29. printf("Direct Instance z = %4.2f + %4.2f j ", z.real, z.imag);

30. printf("Today is %s", ctime(&rawtime));

31. return 0;

32. }

33.

34.

35. struct cplx add(struct cplx a, struct cplx b)

36. {

37. struct cplx c = a; /* can initialise an auto struct variable */

38.

39. c.real += b.real;

40. c.imag += b.imag;

41. return c; /* can return a struct value */

42. }

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?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions