Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Which of the calls to function h in the following program are illegal? Justify y

ID: 3659714 • Letter: W

Question

Which of the calls to function h in the following program are illegal? Justify your answer. PLEASE HELP EXPLAIN WHY THE CALL IS ILLEGAL IN BASIC TERMS(UNDERSTANDABLE)!! #include using nampespace std; void h(int a, int b[], int & c, int & d) { cout << a + b[2] + c + d << endl; } int main() { int x= 3, y = 4, z = 5; int q[]= {1, 5, 7, 12, 15 }; const int W=7; h(W, q[1], y, z); h(y+z, q, z, y); h(q[3], q, y, z); h(3, q, y, z+2); return 0; } I know the first and last calls to function h are illegal, i just need help understanding why they are illegal.

Explanation / Answer

please rate - thanks

#include
using nampespace std;
void h(int a, int b[], int & c, int & d)
{ cout << a + b[2] + c + d << endl; }
int main()
{ int x= 3, y = 4, z = 5;
int q[]= {1, 5, 7, 12, 15 };
const int W=7;
h(W, q[1], y, z); //the parameters passed are int,int,int,int when then must be int, int array, int, int
                          //the 2nd parameter is incompatible
h(y+z, q, z, y);
h(q[3], q, y, z);
h(3, q, y, z+2); //the last parameter passed is a number, when the metod is expecting a reference
                        //parameter, one who's value can be changed
return 0; }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote