Question: #include #define N 1000 typedef struct { char x: long y; char 2; ) s1 t; typedef struct { char x; int y; char z:

#include

#define N 1000

typedef struct {

char x:

long y;

char 2;

) s1 t;

typedef struct {

char x;

int y;

char z:

} s2 t;

typedef struct ( int vals [NI;

) s3 t;

static void func1 (s3 t param) (

param. vals [0] = 200;

]

static void func2 (s3 t *param) (

param-vals [01 = 200;

int main (int arg, char *argv(]) | s3 t s3;

93 t 34;

long long k;

printf ("Size (char) = ld ".

sizeof (char));

printf ("Size (short) = 8ld ", sizeof (short));

printf ("Size (int) = 81d ", sizeof (int));

printf ("Size (long) = 81d ",

sizeof (long));

printf ("Size (long long) = 8ld ", sizeof (k));

printf ("Size (void *) = sld ", sizeof(void *));

printf ("Size (sl_t) = 81d ", sizeof (sl_t));

printf ("Size (s2

t) = id ", sizeof (32_ t)):

s3.vals [0] = 100;

func1 (s3) ;

printf ("s3.vals [0] = 8d ", s3.vals [0]);

s4.vals [0] = 100;

func2 (&s4) ;

printf ("s4.vals [0] = 8d ", s4.vals [0]);

return 0;

}

 #include #define N 1000 typedef struct { char x: long y;

1. Before you compile and run it, predict the values it will print. All non-blank predictions are correct.

(1 point each, total 10 points)

Size(char) = __________

Size(short) = __________

Size(int) = __________

Size(long) = __________

Size(long long) = __________

Size(void *) = __________

Size(s1_t) = __________

Size(s2_t) = __________

s3.vals[0] = __________

s4.vals[0] = __________

2. Now, type it (given c code) in, compile and run it on a fox machine OR personal machine AND rextester.com. Fill in the results here.

(2 points each, total 20 points)

Fox or Personal Machine

Rextester.com

Size(char) =

Size(short) =

Size(int) =

Size(long) =

Size(long long) =

Size(void *) =

Size(s1_t) =

Size(s2_t) =

s3.vals[0] =

s4.vals[0] =

3. Explain the values you got for s1_t and s2_t. Hint: padding. (10 points)

_______________________________________________________________

_______________________________________________________________

_______________________________________________________________

_______________________________________________________________

4. What is the significance of the difference between s3.vals[0] and s4.vals[0]? Which is faster?

(10 points)

_______________________________________________________________

_______________________________________________________________

_______________________________________________________________


Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!