Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) struct dollar 2) { 3) int quarter; 4) int dime; 5) int nickel; 6) int penny;

ID: 3822438 • Letter: 1

Question

1) struct dollar

2) {

3) int quarter;

4) int dime;

5) int nickel;

6) int penny;

7) };

Illustration 2:

21)In reference to Illustration 2 How would a function foo

be declared with a dollar structure as a calling argument?

A) int foo (struct* dollar x);

B) int foo (struct dollar x);

C) int foo (struct dollar);

D) int foo (int dollar x);

22)In reference to Illustration 2 How would a dollar named

'MyMoney' be declared directly?

A) struct dollar MyMoney;

B) struct * dollar MyMoney;

C) struct MyMoney;

D) struct MyMoney dollar;

23) In reference to Illustration 2 How would foo be called

with MyMoney as a calling argument?

A) z = foo( int MyMoney );

B) z = foo( struct MyMoney );

C) z = foo( struct dollar);

D) z = foo( MyMoney );

24)In reference to Illustration 2 How would one of the

components of a dollar be printed in function foo?

A) printf(" The change had %d dimes ”,dime.x);

B) printf(" The change had %d dimes ”,x->dime);

C) printf(" The change had %s dimes ”,x.dime);

D) printf(" The change had %d dimes ”,x.dime);

25)In reference to Illustration 2 How could the parts of a

dollar be initialized as part of the declaration?

A) struct dollar Mine={3, 2, 1, 0,};

B) struct dollar Mine={3; 2; 1; 0};

C) struct dollar Mine={3, 2, 1, 0};

D) struct dollar Mine=[3, 2, 1, 0];

26)In reference to Illustration 2 How could another dollar

instance be created and the pointer 'MyMoneyPtr' be set

to the dollar location?

A) new dollar* MyMoneyPtr = dollar;

B) dollar MyMoneyPtr = new dollar*;

C) dollar* MyMoneyPtr = new dollar;

D) new dollar MyMoneyPtr = dollar*;

27)In reference to Illustration 2 How would a function foo2 be declared with a dollar pointer as a calling argument?

A) int foo2 (struct dollar* xPtr);

B) int foo2 (struct* dollar xPtr);

C) int foo2 (struct dollar xPtr*);

D) int foo2 (*struct dollar xPtr);

28)In reference to Illustration 2 How could foo2 be called

with MyMoneyPtr?

A) z = foo2( MyMoneyPtr* );

B) z = foo2( struct MyMoneyPtr );

C) z = foo2( dollar* MyMoneyPtr );

D) z = foo2( MyMoneyPtr );

29)In reference to Illustration 2 How could foo2 print one

part of a dollar as the calling argument?

A) printf(" The change had %d dimes ”,x.dime);

B) printf(" The change had %d dimes ”,x->dime);

C) printf(" The change had %s dimes ”,x.dime);

D) printf(" The change had %d dimes ”,dime.x);

30)In reference to Illustration 2 Could foo2 change the

contents of the parent dollar?

A) Yes

B) no

C) indirectly

D) using recursion

31)In reference to Illustration 2 Could foo change the

contents of the parent dollar?

A) Yes

B) using recursion

C) indirectly

D) No

Explanation / Answer


struct dollar
{
   int quarter;
   int dime;
   int nickel;
   int penny;
};

21)
   B) int foo (struct dollar x);
22)
   A) struct dollar MyMoney;
23)
   D) z = foo( MyMoney );
24)
   D) printf(" The change had %d dimes ”,x.dime);
25)
   C) struct dollar Mine={3, 2, 1, 0};
26)
   C) dollar* MyMoneyPtr = new dollar;
27)
   A) int foo2 (struct dollar* xPtr);
28)
   D) z = foo2( MyMoneyPtr );
29)
   B) printf(" The change had %d dimes ”,x->dime);
30)
   A) Yes
31)
   D) No