Please help me this question in C++:(I am really want to post them into separate
ID: 3809423 • Letter: P
Question
Please help me this question in C++:(I am really want to post them into separately 2 questions, but because it relates to each other, so I have to post on 1 question- Sorry, and thank you so much for your help)
1a. Given an int array called scores[100] containing 100 test scores, and a function called printArray with an int array parameter called passedArray, write the statement to call the printArray function from main.
1b. Given the array and function from #1a above, write the function header for printArray (a void function). Assume the size has been declared as a global constant called ARRAY_SIZE=10;
Thank you so much.
Explanation / Answer
1a) #include>stdio.h>
#include<iostream.h>
#include<conio.h>
void printArray(int passedArray[] ,int s){
for(int i=0;i<s;i++)
cout<<passedArray[i];
}
void main()
{
int scores[100],n,i;
void printArray(int []);
clrscr();
cout<<"enter number of scores in array acores"; cin>>n;
for(i=0;i<n;i++) cin>>scores[i];
printArray(scores,n);
getch();
return;
}
//if you want scores as fixed 100 then variable n need not be defined.
1b)
#define ARRAY_SIZE 10;
void printArray(int passedArray[])
{
for(int i=0;i<ARRAY_SIZE;i++)
cout<<passedArray[i];
}