Do not use vectors, linked lists, stack/queue libraries Problem: Write a C++ pro
ID: 3815053 • Letter: D
Question
Do not use vectors, linked lists, stack/queue librariesProblem: Write a C++ program that does the following 1. Accepts array size from the keyboard. Size must be a positive integer that is 4. 2. Use the size from step 1 in order to create an integer array. Populate the created array with random integer values between 25 and 500 inclusive 3. Display the generated array. 4. Recursive Table of Squares Write a function that uses recursion in order to display squares of integers in ascending order, starting from 1 to last number in the array 5. Recursive Power Function Write a function that uses recursion to raise a number to a power. The function should take two arguments, the number to be raised to the power is the first number in array and the power is 2. 6. Recursive sumofSquares function Write a function named sumofSquares that return the sums of squares of the numbers from 0 to a Array of SizE 2. Do not use global variable
Explanation / Answer
1.
#include <iostream>
using namespace std;
int main()
{
cout<<"ENter the size of an array:";
int size=0;
cin>>size;
while(size <4)
{
cout<<"please enter the size greater than 4 :";
cin>>size;
if(size>4)
break;
}
return 0;
}
2.
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
cout<<"ENter the size of an array:";
int size=0,i,min=25;max=50,num=-1;
cin>>size;
int array[size];
while(size <4)
{
cout<<"please enter the size greater than 4 :";
cin>>size;
if(size>4)
break;
}
for(i=0;i<=size;i++)
{
num=min+rand()%((max-min)+1);
array[i]=num;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.