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 5 articles in this topic
Showing 5 of 831 articles.
Currently no other people reading this forum.


 UWA week 34 (2nd semester, week 5) ↓
SVG not supported

Login to reply

👍?
helpful
8:13am Wed 21st Aug, ANONYMOUS

How can the answer still be A when line A is valid and line C contains a syntax error?


SVG not supported

Login to reply

👍?
helpful
8:15am Wed 21st Aug, Christopher M.

ANONYMOUS wrote:
> How can the answer still be A when line A is valid and line C contains a syntax error?
Line A is not valid, and line C does not contain a syntax error. Cut-paste-compile the code if you need to.


SVG not supported

Login to reply

👍?
helpful
1:51pm Wed 21st Aug, ANONYMOUS

Wouldn't this mean that A and B are incorrect. Since we define N as 10; // which includes the semicolon. That means for A, Substitution: char array[10;]; The semicolon causes a syntax error here. For B, int x = 2 * 10;; This results in a double semicolon (;;), which is a syntax error. For C, I think that is okay for the semicolon to be before ++i Thanks!


SVG not supported

Login to reply

👍x1
helpful
2:01pm Wed 21st Aug, ANONYMOUS
✅ content verified by our teaching staff  

Not sure if I am correct but the reason why B (int x = 2 * 10;;) is because it would take the second semicolon as an empty statement so it'll be read as int x = 2 * 10; ; which would not affect the program itself but will just look weird and isn't good practice


SVG not supported

Login to reply

👍?
helpful
2:21pm Wed 21st Aug, Christopher M.

ANONYMOUS wrote:
> Not sure if I am correct but the reason why B (int x = 2 * 10;;) is because it would take the second semicolon as an empty statement so it'll be read as > int x = 2 * 10; > ; > which would not affect the program itself but will just look weird and isn't good practice
This is the correct reasoning.

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