Pointers in C programming with double precision -


ok must can't make work:

a) change float instead of integers. , assign 0.3 starting value "u".

b) use double precision instead of integers. asign 0.3x10^45 starting value "u".

c) use characters instead of integers. assign starting value 'c' "u".

#include <stdio.h> main () { int u = 3; int v; int *pu; int *pv; pu = &u; v = *pu; pv = &v;  printf("\nu=%d     &u=%x    pu=%x  *pu=%d", u, &u, pu, *pu); printf("\n\nv=%d    &v=%x    pv=%x  *pv=%d", v, &v, pv, *pv); } 

i'll grateful if modify code things above. thanks

this question testing few things. first know types? expected know floating pointing number declared float, double precision number double, , character char.

second expected know how assign literal value different types. float literal expected use 0.3f, since without suffix double precision default (although in context isn't going make difference). double, expected know how use scientific notation (the literal value should 0.3e45). character literal hope obvious you.

finally expected know various type characters used in printf format specification. both single , double precision numbers use same type characters, have choice of %e, %f or %g, depending on requirements. tend use %g general purpose choice, guess expecing use %e double (because forces use of scientific notation) , possibly %f float - depends have been taught. character use %c.

also, note should replacing %d type characters in format strings. %x values used output hexadecimal representation of pointers (&u , pu). pointer isn't going change floating point value or character because type being pointed has changed - address integer when writing out.


Comments