Please answer the queston (in terms of C programming) and explain answer End of
ID: 3905888 • Letter: P
Question
Please answer the queston (in terms of C programming) and explain answer
End of Semester 1, 2016 COMP1004 Engineering Programming Question 1 Fundamentals (20 marks) 1(a) The following C program has three (3) syntax errors/warnings in it when compiled. Identify and correct the errors by stating the line number where they occur. Note: In Line 310, the line overflow is not an error [3 marks cach, 9 marks in total] 10 #include 20 #include 30 40 #define PIE 3.14159 50 60 int main(void) 70 80 define the required variables/ 90 int length; 100 float ext_diam, int_diam, ext_rad, int_ rad; 110 float area, volume, mass 120 const float density= 8030.0; 130 140 150 prompt and get values 160 printf ("input the external diameter of the pipe in metres:") 170 scanf ("f", ex: diam); 180 printf ("input the internal diameter of the pipe in metres: " 190 scanf (",int diam); 200 210 do calculations area of pipe cross-section, volume 220 of pipe and mass of pipe / 230 240 ext rad ext diam 2.0 250 int rad int_diam2.0 260 270 area(PI ext rad ext rad (PT pow (inc rad, 2)) 280 Eor(length 1length 10;iengh+) volume area length (Eloar) mass volumedensity printf ("The mass of the pipe of length im is 290 Ekg ", length, mass); 320 330 340 return 0 350Explanation / Answer
Line 270: --------- 2 changes here. We have defined PIE in line 40. So, we have to use that PIE here not PI. FIX: area = (PIE * ext_rad * ext_rad) - (PIE * pow(int_rad,2)); Line 290: ---------- 1 changes here. FIX: volume = area * (float) length;