Section B: Program Testing [25 marks] 7. Is the following if statement legal in C? if (n >= 1 <=10) printf("n is between

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Section B: Program Testing [25 marks] 7. Is the following if statement legal in C? if (n >= 1 <=10) printf("n is between

Post by answerhappygod »

Section B Program Testing 25 Marks 7 Is The Following If Statement Legal In C If N 1 10 Printf N Is Between 1
Section B Program Testing 25 Marks 7 Is The Following If Statement Legal In C If N 1 10 Printf N Is Between 1 (87 KiB) Viewed 60 times
Section B: Program Testing [25 marks] 7. Is the following if statement legal in C? if (n >= 1 <=10) printf("n is between 1 and 10\n"); If so, what does if do when n is equal to 0? [3] 8. Given a triangle with a base b and a height h its area is A = bxh. The following piece of C code which computes the area of a triangle contains errors. Locate the errors and show how to fix them. [5] float area_of_triangle (float base, height) float product; { product = base+height return (product/2 } 9. The following piece of code must print the number of negative values in the array Integer. Locate the errors and show how to fix them. [5] = int Integer[] = {-5,1,3,7,8,-1,-3,-7,3,10]; int i; n=0; while (n <= 10) { n += (Integer < 0)? 1:0; i; } printf("%d ", n); 4
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply