Assume that the functions CS303 and UMKC have been defined as follows:
int CS303(int n) {
if (n == 0) {
return 1;
} else {
return UMKC(2, CS303(n - 1));
}
}
int UMKC(int n1, int n2) {
if (n1 == 0) {
return 0;
} else {
return n2 + UMKC(n1 - 1, n2);
}
}
What is the value of CS303(4)?
:
Answer: 16
OUTPUT:
I ADD TWO FUNCTIONS IN THE MAIN FUNCTION OF C LANGUAGE
AND EXECUTE;
TWO FUNCTIONS CALLS RECURSIVELY BASED ON THE ARGUMENTS VALUES
CODE:
#include <stdio.h>
int CS303(int n)
{
if (n == 0)
{
return 1;
} else
{
return UMKC(2, CS303(n - 1));
}
}
int UMKC(int n1, int n2)
{
if (n1 == 0) {
return 0;
}
else
{
return n2 + UMKC(n1 - 1, n2);
}
}
int main()
{
int val=CS303(4);
printf("%d",val);
return 0;
}
SCREENSHOT OF THE CODE:
Get Answers For Free
Most questions answered within 1 hours.