Question 1 Consider the following C code fragments and answer the associated que
ID: 3892347 • Letter: Q
Question
Question 1 Consider the following C code fragments and answer the associated questions. Assume that the code is running on a STM32F407 processor which is little endian. The stdint.h data types have been used which indicate data size explicitly. Note that some code fragments may not give useful results.
a) Describe the result of the printf() statement in the following code fragment.
int32_t test(int32_t a, int8_t b)
{
return b >> 1 * a;
}
main()
{
printf("%x ", test);
}
b) What is the result of the printf() statement in the following code fragment?
int8_t a[] = {0x12, 0xb2, 0x37, 0xc8};
printf("%x ", a[2] | (0x08) & a[3]);
c) What is the result of the printf() statement in the following code fragment?
int8_t a[] = {0x11, 0xa2, 0x36, 0x55, 0x44, 0x33};
printf("%x ", *((alt_16 *) a + 2));
d) What is the result of the printf() statement in the following code fragment?
int8_t a[] = "ELEC3730 Is Fun!";
a[5] = a[10] = a[15] = 0;
printf("%s %s %s ", a+2, a+7, a+12);
e) What is the result of the printf() statements in the following code fragment?
int32_t process()
{
static int32_t t = 10;
t = 2*t;
return t;
}
main()
{
printf("%d, %d, %d ", process(), process(), process());
}
Explanation / Answer
If you need any explanation, please give me comment...
a) 400530
b) 3f
c) 3344
d) EC3 0 I Fun
e) 80, 40, 20
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.