1. Homepage
  2. Exam
  3. [2019] ENG 1002 Programming (Matlab and C) - Semester 1 - Primary Examination - Q10 Defensive Programming in C

[2019] ENG 1002 Programming (Matlab and C) - Semester 1 - Primary Examination - Q10 Defensive Programming in C

This question has been solved
Engage in a Conversation

Question 10
Defensive Programming in C - fundamental C programming structures
CourseNana.COM

(a) What will be the value of counter printed when the following code runs? Explain your answer CourseNana.COM

               int increment(int counter) { CourseNana.COM

                              counter++; CourseNana.COM

                               return 0; CourseNana.COM

               } CourseNana.COM

               int main(void) { CourseNana.COM

                               int counter = 4; CourseNana.COM

  CourseNana.COM

                                 if (counter > 0) { CourseNana.COM

                                                int counter = increment(counter); CourseNana.COM

                                 } else { CourseNana.COM

                                                increment(counter); CourseNana.COM

                              } CourseNana.COM

                                 printf("%d\n", counter); CourseNana.COM

                 } CourseNana.COM

(b) Write a C program that asks the user to enter up to 20 characters and then prints the characters the user entered in reverse. The program should stop accepting characters when the user enters a non-alphabetic character (ie anything other than a, b, c .... z or A, B, C .... Z) CourseNana.COM

(c) Explain two risks to running C programs and defensive programming techniques you can use to mitigate them in your code. CourseNana.COM

[Total for Question 10: 17 marks] CourseNana.COM

Get the Solution to This Question

WeChat WeChat
Whatsapp WhatsApp
The University of Adelaide代写,ENG 1002代写,Programming (Matlab and C)代写,C代写,Matlab代写,The University of Adelaide代编,ENG 1002代编,Programming (Matlab and C)代编,C代编,Matlab代编,The University of Adelaide代考,ENG 1002代考,Programming (Matlab and C)代考,C代考,Matlab代考,The University of Adelaidehelp,ENG 1002help,Programming (Matlab and C)help,Chelp,Matlabhelp,The University of Adelaide作业代写,ENG 1002作业代写,Programming (Matlab and C)作业代写,C作业代写,Matlab作业代写,The University of Adelaide编程代写,ENG 1002编程代写,Programming (Matlab and C)编程代写,C编程代写,Matlab编程代写,The University of Adelaideprogramming help,ENG 1002programming help,Programming (Matlab and C)programming help,Cprogramming help,Matlabprogramming help,The University of Adelaideassignment help,ENG 1002assignment help,Programming (Matlab and C)assignment help,Cassignment help,Matlabassignment help,The University of Adelaidesolution,ENG 1002solution,Programming (Matlab and C)solution,Csolution,Matlabsolution,