Declare a function named average that takes an integer array and the size of the
ID: 3837264 • Letter: D
Question
Declare a function named average that takes an integer array and the size of the array as an argument. The return value is a double. If variable p is a pointer and it points to the base address of an integer array, use variable p to set the value at index 5 of the array to the value 5. Name a function in the C standard libraries (i.e. in stdio.h) that uses pass by reference. Show the LC-3 assembly code for pushing the value in R5 onto the runtime stack. Declare a struct that holds an integer array of length 10 and a character array of length 10. Declare a struct suitable for representing a linked list. Write an expression for an int value with an alternating bit pattern (e.g. 0101b) that fills up all 32 bits of the integer. Write an expression that evaluates to true. You may not declare or use anyExplanation / Answer
R.
double average(int arr[], int n) {
double sum = 0;
int i = 0;
for(i=0; i<n; i++)
sum = sum + arr[i];
return sum/n;
}
S.
int *p = arr;
p[4] = 5;
T.
scanf() function used call by reference
V.
struct s{
int intArr[10];
char charArr[10];
};
W.
struct node{
int data;
struct node *next;
};
X.
3 > 2 -> evaluates to true
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.