C program, pointers
1.
Struct twofloats{
Float f1;
Float f2:
Int * p;
}
Void do_smthng(struct twofloats tf) {
tf.f1 = 0.0;
tf.f2 = 1.0;
}
Main(){
struct twofloats s1 = {16.65,33.3};
Int x = 5;
s1.p = &x;
struct twofloats s2 = s1;
s2.f2 = 10.1;
*(s2.p)=55;
printf (“%d %d %d %d n”, (Int)s1.f1,(Int)s1.f2, (Int)s2.f1, (Int)s2.f2);
printf(“%d %d n”, *(s1.p), *(s2.p));
Do_smthng(s2);
Printf(“%d %d n”, (Int)s2.f1, (Int)s2.f2 l;
//what are the outputs of printf, do_smth?
2.
Complete program so output is 16.400, 30.600 double the field values
Struct twofloats{
Float f1;
Float f2;
}
// complete code below
Void do_smt( ) {
}
main() {
struct twofloats s = {8.2,15.3};
do_smt( ) ; //complete code here
Printf(“%.3f %.3fn”, s.f1, s.f2);