Question: #include using namespace std; #define ArraySize 15 #include //Prototype double power(double base, int exponent); int gcd(int x, int y); int recursiveMinimum(int a[], int n); void

#include

using namespace std;

#define ArraySize 15

#include

//Prototype

double power(double base, int exponent);

int gcd(int x, int y);

int recursiveMinimum(int a[], int n);

void main() {

cout << "-----------------PROGRAM MENU----------------------" << endl;

cout << "For Recursive Exponentiation Select 1 : " << endl;

cout << "For Recursive Greatest Common Divisor Select 2 : " << endl;

cout << "For Find the Minimum Value in an array Select 3 : " << endl;

cout << "--------------------------------------------------- " << endl;

cout << "Select your Choice : ";

int choice;

cin >> choice;

cout << " ";

switch (choice)

{

case 1:

cout << "-----Recursive Exponentiation Starts now.----- " << endl;

double base;

int degree;

cout << "Enter Base :";

cin >> base;

cout << "Enter Exponent : ";

cin >> degree;

cout << "Number " << base << " raised to " << degree << " is: " << power(base, degree) << endl;

cout << endl;

break;

case 2:

cout << "----Recursive Greatest Common Divisor starts now.---- " << endl;

int number1, number2;

cout << "Enter 1st Number :";

cin >> number1;

cout << "Enter 2nd Number :";

cin >> number2;

cout << "Greatest Common Divisor of " << number1 << " & " << number2 << " is : " << gcd(number1, number2) << " " << endl;

break;

case 3:

cout << "-----Find the Minimum Value in an array starts now.----- " << endl;

int smallestNum, testArray[15];

srand(time(NULL)); //Seed Null value, We shall get every time the dynamic sequence

int i;

//Fill Array with random numbers.

for (i = 0; i < ArraySize; i++) {

testArray[i] = rand() % 500; //Generate in the range of 200 and below.

}

cout << "Array elements are: " << endl;

//Display the elements of Array filled by Random Numbers

for (i = 0; i < ArraySize; i++) {

cout << testArray[i] << " ";

}

smallestNum = recursiveMinimum(testArray, ArraySize);

cout << " Smallest value in Array is : " << smallestNum << endl;

break;

default:

cout << "Invalid Selection" << endl;

}

system("PAUSE");

}

//1:Recursive Exponentiation

double power(double base, int exponent)

{

if (exponent == 1)

return base;

else

return base * power(base, exponent - 1);

}

//2:Recursive Greatest Common Divisor

int gcd(int x, int y)

{

if (y == 0)

return x;

else return gcd(y, x % y);

}

//3:Find the Minimum Value in an array

int recursiveMinimum(int a[], int n)

{

if (n == 1)

return a[0];

n--;

return recursiveMinimum(a + (a[0] > a[n]), n);

}

Hi can u change this to from c++ to c program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!