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

cod 1.0798 ) Files > exercise #1.htm exercise #1.htm Download exercise #1.htm (4

ID: 3745316 • Letter: C

Question

cod 1.0798 ) Files > exercise #1.htm exercise #1.htm Download exercise #1.htm (41.9 KB) Problem . Declare two short int variables, two int variables, and two long int variables and then output the address of each variable b. Calculate the size of the memory location allocated to each type by subtracting the address of the first variable from the address of the second variable of the same type. Repeat the problem above but with two float variables, two double variables and two long double variables (inclpding a and b sections). DELL

Explanation / Answer

#include<stdio.h>

int main()
{
int a,_a;
short int b,_b;
long int c,_c;

float d,_d;
double e,_e;
long double f,_f;

printf(" +++++++++++++++++++++++ int +++++++++++++++++++++++ ");

printf(" .................... Addresses .................... ");
printf(" Address of int variavle(a) is %u ",&a);
printf(" Address of int variavle(_a) is %u ",&_a);
printf(" Address of short int variavle(b) is %u ",&b);
printf(" Address of short int variavle(_b) is %u ",&_b);
printf(" Address of long int variavle(c) is %u ",&c);
printf(" Address of long int variavle(_c) is %u ",&_c);
printf(" .................... Addresses .................... ");

printf(" ");

printf(" ...................... Sizes ...................... ");
a=(int)&a;
_a=(int)&_a;
printf(" int have size %d ",a-_a);

b=(int)&b;
_b=(int)&_b;
printf(" short int have size %d ",b-_b);

c=(int)&c;
_c=(int)&_c;
printf(" long int have size %d ",c-_c);
printf(" ...................... Sizes ...................... ");

printf(" +++++++++++++++++++++++ int +++++++++++++++++++++++ ");

printf(" ");

printf(" +++++++++++++++++++++++ float +++++++++++++++++++++++ ");

printf(" .................... Addresses .................... ");
printf(" Address of float variavle(d) is %u ",&d);
printf(" Address of float variavle(_d) is %u ",&_d);
printf(" Address of double variavle(e) is %u ",&e);
printf(" Address of double variavle(_e) is %u ",&_e);
printf(" Address of long double variavle(f) is %u ",&f);
printf(" Address of long double variavle(_f) is %u ",&_f);
printf(" .................... Addresses .................... ");

printf(" ");

printf(" ...................... Sizes ...................... ");
printf(" float have size %d ",((int)(&d))-((int)(&_d)));

printf(" double have size %d ",((int)(&e))-((int)(&_e)));

printf(" long double have size %d ",((int)(&f))-((int)(&_f)));

printf(" ...................... Sizes ...................... ");
printf(" +++++++++++++++++++++++ float +++++++++++++++++++++++ ");

return 0;
}