Tuesday, July 28, 2009

Look at this program: Answer the ?'s -please?

#include%26lt;stdio.h%26gt;





struct vector


{


float x;


float y;


float z;


};


float scalar (vector*, vector *);


int main(void)


{


struct vector a ={2.3,4.2, 6.5};


struct vector b = {-1.2, 3.5, 5.1};


printf ("the answer is %.2f", scalar (%26amp;a, %26amp;b));


}


float scalar (struct vector*po1, struct vector *po2)


{


float s;


s= po1-%26gt;x*po2-%26gt;x + po1-%26gt;y*po2-%26gt;y+po1-%26gt;z*po2-%26gt;z;


return (s);


}





After running this program the screen will:


a. 45.0900000


b.45.09


c. the answer is 45.09


d. the answer is 45.090000





Also:


the scalar( ) function uses po1-%26gt;x to access the 1st member of the structure which other one can be equally used to access the same member?





a. po1.x


b. *po1.x


c.(*po1).x


d. a.x

Look at this program: Answer the ?'s -please?
both answers are c.
Reply:It won't compile for me. = ( it closes right away.


No comments:

Post a Comment