//self studying exercises, no need to submit to the teacher. // Appendix: testing C and assembly conversion // run this program and read contents in the disassembly window in uvision //Exercises: Use single step to run it, and answer the questions below. #include int a[4],b[4],c,i; main() { for(;;) //testing forever { //test 1, looping for (i=1;i<10;i++) { if (i <= 5) c = 0; else c = 1; } //Question1a: Where does the program store i and c? //Question1b: Draw the flow diagram of the program. //test 2, looping and array for (i = 0; i < 4; i++) {a[i]=0; b[i]=0;//clear the arrays } for (i = 0; i < 10; i++) {a[i]=3+i; //set values into the array }//question2a: Find a bug in the above program. //question2b: What is the actual result of running the code? //test 3, looping i=0,c=0; //clear i,c while (i<5) {c++; i++; } //Question3a: Where does the program store i and c? //Question3b: Draw the flow diagram of the program. //test 4, test switching i=0,c=1; //clear variables for(i=0;i<5;i++) { switch (i) { case 0: c=0; case 1: c=1; case 2: c=2; case 3: c=3; case 4: c=4; default: c=0; } } } //question4a: Explain how switch-case is implemented here. //question4b: Suggest an alternative method for the implementation. }