It's UWAweek 47

help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.
Displaying the 4 articles in this topic
Showing 4 of 828 articles.
Currently 107 other people reading this forum.


 UWA week 33 (2nd semester, week 4) ↓
SVG not supported

Login to reply

👍?
helpful
12:01pm Wed 14th Aug, ANONYMOUS

For the question 12 void function(void) { for (int i = 0; i < 5; ++i) { switch (i % 3) { case 0: printf("%i ", i); break; case 1: printf("%i ", i); break; } } printf("\n"); } The options for the output are: A. 0 1 2 3 4 B. 1 3 5 C. 0 0 1 3 3 4 D. 0 1 1 2 3 4 4 can u please confirm what will be the correct output? my output doesn't match the options. maybe I am wrong :)idk


SVG not supported

Login to reply

👍?
helpful
5:10pm Wed 14th Aug, Joshua N.

ANONYMOUS wrote:
> For the question 12 > > void function(void) { > for (int i = 0; i < 5; ++i) { > switch (i % 3) { > case 0: > printf("%i ", i); > break; > case 1: > printf("%i ", i); > break; > } > } > printf("\n"); > } > The options for the output are: > A. 0 1 2 3 4 > B. 1 3 5 > C. 0 0 1 3 3 4 > D. 0 1 1 2 3 4 4 > > can u please confirm what will be the correct output? my output doesn't match the options. maybe I am wrong :)idk
You're right. I think there is a typo in the answer. None of the options are correct. However, there is one option that is very close to the correct answer. Can you see which one it is?


SVG not supported

Login to reply

👍?
helpful
7:23pm Wed 14th Aug, Chenjun H.
✅ content verified by our teaching staff  

The code in the question doesn't have any breaks in the switch statement, remember that c has switch fall through by default, which should make the answer self evident.


SVG not supported

Login to reply

👍x1
helpful
5:37am Thu 15th Aug, Christopher M.

"Chenjun Hou" <23*6*8*9@s*u*e*t*u*a*e*u*a*> wrote:
> The code in the question doesn't have any breaks in the switch statement, remember that c has switch fall through by default, which should make the answer self evident.
This is the correct 'answer', thank you. I wonder how/why the OP has break statements in the posted question. Perhaps they had been introduced by an IDE trying to be helpful by (incorrectly) anticipating what was coming 'next' ??

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy