Question 3: Error Detection and Correction [5 marks] Each of the following short C codes (or segments) contains one or m

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
correctanswer
Posts: 43759
Joined: Sat Aug 07, 2021 7:38 am

Question 3: Error Detection and Correction [5 marks] Each of the following short C codes (or segments) contains one or m

Post by correctanswer »

Question 3 Error Detection And Correction 5 Marks Each Of The Following Short C Codes Or Segments Contains One Or M 1
Question 3 Error Detection And Correction 5 Marks Each Of The Following Short C Codes Or Segments Contains One Or M 1 (50.49 KiB) Viewed 77 times
Question 3: Error Detection and Correction [5 marks] Each of the following short C codes (or segments) contains one or more syntax and/or logic errors. Find ONE such error from each code (or segment) and correct it accordingly (e.g., by pointing out the part of the code that contains error/s and replacing it with your correct code segment). (1 mark each) 1) int main() { int distance, time, speed; speed distance / time; printf("Speed is: %d \n", speed); return 0; } 2) double height, centimetre=185; height = 1/100 * centimetre; printf("His height is: %d metre!\n", height); 3) #define GRAVITY 9.8 double speed = 0, terminalVelocity = 100.0; while (speed < terminalVelocity); { speed + GRAVITY; printf(" Speed = %d\n", speed); //height in metre
4) = {1,2,3,4,5,6,7,8,9,0}; int i=0, Array1[10], Array2 [10] Array1 = Array2; for (i=0; i<10; i++) { printf ("%d + %d = %d\n", Array¹, Array2, Array1+Array2); } 5) double calculateAverage (double first, double second) { double average = first + second / 2; return average; }
Register for solutions, replies, and use board search function. Answer Happy Forum is an archive of questions covering all technical subjects across the Internet.
Post Reply