Write 4 separate ARM functions, one to perform each of the following tasks. Do n
ID: 2079291 • Letter: W
Question
Write 4 separate ARM functions, one to perform each of the following tasks. Do not write the code which CALLS these functions, just write the functions themselves. A function named ANSWER which takes no arguments and returns the 42 A function named SUM which takes two arguments and returns the sum A function named MAX which takes three arguments. This function adds together the arguments then checks the sum. If the sum is greater than 15, the function returns 1. If the sum is less than or equal to 15, the function returns 0. A function called FOLD which takes two arguments. The first argument is the address of the first number in an array of numbers. The second argument is the length of the array. The function sums together all the numbers in the array and returns the sum.Explanation / Answer
int ANSWER(){
int p = 42;
return (p);
}
int SUM(int a, int b){
int sum1 = a+b;
return (sum1);
}
int MAX(int a, int b,int c){
int tot = a+b+c;
if(tot > 15)
return 1;
else
return 0;
}
int FOLD(int *ptr,int arraylen ){
int tempsum = 0;
int i;
for( i =0;i<arraylen;i++){
tempsum = tempsum + *ptr;
ptr = ptr + 1;
}
return tempsum;
}
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.