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

28. What is a valid C-+ function that computes and retums an integer value which

ID: 3920334 • Letter: 2

Question

28. What is a valid C-+ function that computes and retums an integer value which is the number of values in the array which are greater than 0? OA) int positive ( double xi 1. int npts) ( int npos 0; for (int k =0;k 0) npos++) return npos; ) OB) int positive ( double xI1, int npts) ( int npos 0; fondmo.kts k if (xk> 0) npos+ return npos; ) OC) int positive ( double xI 1. int npts) {int rpo s = 0; for (int k 0; k 0) npos++:) return npos; ) OD) int positive ( double x( 1. int npts) int npos 0; for (int k 0; k 0) npos++ ) etum npts;) 29. MATLAB is a "case-sensitive" computing language. A) False OB) True

Explanation / Answer

28. Option B is correct. We first take a counter and initialize it with 0. Then in loop check all values which are greater than 0 and increment the counter npos. At last return npos.

29. Matlab is a case sensitive language, it differentiate different case variables and methods.

30. x value starts from 1. then after one iteration becomes 4, then in next iteration becomes 7. After than it becomes 10 which breaks the loop, hence it doesn't count. So sum is sum of 1, 4, and 7. Answer is 12. option B

If the answer helps you, please upvote. Thanks!

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