USING C++ PROGRAM PLEASE Program 2- (30) Write a program that behaves as follows
ID: 3760699 • Letter: U
Question
USING C++ PROGRAM PLEASE
Program 2- (30) Write a program that behaves as follows: . Stores the following order of integers in array A: 7,3,5,3,8,9,1,5,1,8,4,3,7,3,9 . Asks user for an integer B. . If 0 less than equal to B less than equal to 14, change all elements of A to A[B]. Otherwise, the program exits without doing anything more. . You should implement a function ... that takes as input an array A and an integer B, and change the values of array A. . Program should print the result. . Sample outputs: Enter the number: 4 8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8 Enter the number: 17Explanation / Answer
#include<iostream.h>
using namespace std
void repeat_number(int a[],int b)
{
for (int i=0;i<15;i++)
{ if ( (b>0) && (b<1=4))
a[i]=b;
}
// Display the output
for(i=0;i<15;i++)
cout << a[i]
}
int main()
{
int a[15]={7,3,5,3,8,9,1,5,1,8,4,3,7,3,9};
cout <<" Enter B value ";
cin>>b;
repeat_number(a,b);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.