I need to turn in my homework by Monday morning, and I have noidea how to work w
ID: 3615791 • Letter: I
Question
I need to turn in my homework by Monday morning, and I have noidea how to work with recursion. Please help me out. I willrate
All of those functions have to be in the same program withoutusing any loops
-Multiply a*b, but we cannot use any arithmetic operators except++ and --;
Unsigned multiply (unsigned a, unsigned b)
-Return the number of chars in s, not counting the terminatingnull char. Don’t use strlen, have the function find out thelength
intstringLength (const char s[])
-Return 1 if all the chars in are digits, return 0 otherwise
allDigits(const char[])
-Return the number represented in the string. For instancevalue(“1234”) would return 1234. You may assume withoutchecking that if the arg were passed to allDigits. allDigits willreturn 1
value ( const char s[])
-Return the sum of all size elements of the array
double sum (const double a[], unsigned size)
-Return the product of all size elements of the array
double sum (const double a[], unsigned size)
-Return the maximum value if all size elements of the array
double max (const double a[], unsigned size)
-Return the minimum value if all size elements of the array
double min (const double a[], unsigned size)
-Return the index of the maximum value.
unsigned maxIndex (const double a[], unsigned size)
-Return the index of the minimum value.
unsigned maxIndex (const double a[], unsigned size)
-We assume that both array arg have the size elements. Thefunction’s job is to copy all the value from b to thecorresponding positions in a.
void coppyArray (double a[], const double b[], unsigned size)
Thank you so much.
Explanation / Answer
please rate - thanks best I can do, but some is better than none! #include #include unsigned multiply (unsigned a, unsigned b); double sum (const double a[], unsigned size); double product (const double a[], unsigned size); double max (const double a[], unsigned size); double min (const double a[], unsigned size); int main() { printf("multiply(3,5)=%d ",multiply(3,5)); double a[]={2,1,5,3,4}; printf("sum(2,1,5,3,4)=%f ",sum(a,5)); printf("product(2,1,5,3,4)=%f ",product(a,5)); printf("max(2,1,5,3,4)=%f ",max(a,5)); getch(); return 0; } double max (const double a[], unsigned size) {double temp; if(size == 1 ) return a[0]; else {temp=max(a, size-1); if (temp>a[size]) return temp; else return a[size]; } } double product (const double a[], unsigned size) { if (size==0) return 1; else return product( a, size - 1 ) * a[size - 1 ]; } double sum (const double a[], unsigned size) { if (size==0) return 0; else return sum( a, size - 1 ) + a[ size- 1 ]; } unsigned multiply (unsigned a, unsigned b) {unsigned result; if(b==1) returna; else return a +multiply(a, b-1); }Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.