a. Fill in the units? (4 pts) 10 seconds (answer given) 10 seconds 210 Bytes 230
ID: 3881791 • Letter: A
Question
a. Fill in the units? (4 pts) 10 seconds (answer given) 10 seconds 210 Bytes 230 Bytes 10 Hz ms b. Period or frequency (1 pt) How many positive edges of a 1 MHz clock will occur in 10 ms? Reminder: Assume a TM4C123 is being used unless specified otherwise For each declaration, indicate how many bytes will be allocated in memory (2 pts) i) i) a. int sensor_readings (100) signed short scandata [20) [20] b. For each, indicate the value of my length after executing each fragment of C code. Function strlen is a standard C library function. Specify N/A if the value of my_length cannot be determined. (4 pts) my length is char msg[] = "CPRE288"; int mylength = 0xFFFFFFFF; - my-length = strlen (msg); ii) my length is char msg [7] = int my-length "CPRE2 88"; = 0xFFFFFFFF; my-length = strlen (msg); ii) my length is char msg [ 100] int my-length { ,C' , , P' , , R' , 'E, , ', ,2, ,8" ,8, ,10, } ; 0xFFFFFFFF; my-length = strlen (msg); v) my length is 2, 0, 3, 5, 77, 23); char msg [ ] = {5, 7, 10, 0, 9, int my-length = 0xFFFFFFFF; my-length = strlen (msg + 4);Explanation / Answer
a.
1ms = 10-3 seconds
1ns = 10-9 seconds
1KB = 210 Bytes
1GB = 230 Bytes
1MHz = 106 Hz
b.
In 1 sec if the frequency is 1MHz (this represents the positive edges in 1 sec), then in 10ms frequency will be as follows:
= 10ms * 1MHz
= 10 * 10-3 * 1 * 106
= 10 * 103
= 104
Thus, the number of positive edges in 10ms will be 104.
a.
b.
(i)
my_length is 7.
char msg[] = “CPRE288”;
int my_length = 0xFFFFFFFF;
my_length = strlen(msg);
Explanation:
If the size in the array is not given, then the program will consider the size of array
equals to number of characters in the array.
Hence, the value of my_length is 7.
(ii)
my_length is 14.
char msg[7] = “CPRE288”;
int my_length = 0xFFFFFFFF;
my_length = strlen(msg);
Explanation:
Here, the value of strlen(msg) depends on the initialization of my_length. Hence, it
will change as the value at the time of initialization changes. At 0xFFFFFFFF, the
value iof my_length is 14.
Hence, the value of my_length is 14.
(iii)
my_length is 4.
char msg[100] = {‘C’, ‘P’, ‘R’, ‘E’, ‘’, ‘2’, ‘8’, ‘8’, ‘’};
int my_length = 0xFFFFFFFF;
my_length = strlen(msg);
Explanation:
‘’ is considered as the null character and end of string.
Thus, before ‘’, there are 4 characters.
Hence, the value of my_length is 4.
(iv)
my_length is 2.
char msg[] = {5, 7, 10, 0, 9, 2, 0, 3, 5, 77, 23};
int my_length = 0xFFFFFFFF;
my_length = strlen(msg + 4);
Explanation:
The strlen(msg+4) will calculate the length from 4th index. So, at 4th index the value if
9. And at 7th index the value is 0. The ASCII value of 0 is null. So, strlen function will
calculate the value before the 0.
Hence, the value of my_length is 2.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.