PLEASE NOTE: the upgrades to this server, secure.csse.uwa.edu.au, have not yet been completed.
Hopefully the changes will be completed on THURSDAY 8th December.
Web-based programs, such as csmarks, cssubmit, and the help fora, will be unavailable at some time on Thursday 8th.
  It's UWAweek 49

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 6 articles in this topic
Showing 6 of 919 articles.
Currently 3 other people reading this forum.


 UWA week 37 (2nd semester, week 7) ↓
SVG not supported

Login to reply

👍?
helpful
5:41pm Sat 17th Sep, Haoxuan L.

Why is the answer for q10 A? my answer is C because of missing semicolon



This article has 1 attachment:

 

SVG not supported

Login to reply

👍?
helpful
7:07pm Sat 17th Sep, ANONYMOUS

If I'm not mistaken, the preprocessor will throw a fit at: #define N 10 ; Since a semicolon is given, that makes it array[10;] . Semicolons aren't preprocessor directives. [Link][stackoverflow] C is also a syntax error, but the first error is the array declaration, so perhaps that's why. There's also no A,C option. Trick question?


SVG not supported

Login to reply

👍?
helpful
2:01pm Sun 18th Sep, Christopher M.

"Haoxuan Long" <23*4*1*[email protected]*u*e*t*u*a*e*u*a*> wrote:
> Why is the answer for q10 A? > my answer is C because of missing semicolon
Line C does not contain a syntax error. The output from the C-preprocessor for Line C is: for(int i=0 ; i<10; ++i) { which is perfectly valid.


SVG not supported

Login to reply

👍x1
helpful
2:07pm Sun 18th Sep, Christopher M.

ANONYMOUS wrote:
> If I'm not mistaken, the preprocessor will throw a fit at: #define N 10 ;
There's nothing invalid about having a semicolon on a pre-processor line. A frequently seen technique, attempting to make code more readable, is to use something like:
 #define  FOREACH_NODE       for(int n=0 ; n < nnodes ; ++n)
Remember that the pre-processor is performing textual substitution, and doesn't need/attempt to check the validity of C syntax, and can be used as a general utility to modify any text (not just programs).


SVG not supported

Login to reply

👍?
helpful
3:33pm Sun 18th Sep, ANONYMOUS

Ah thanks for clarifying; then it'll fail at the array initialization. 👍


SVG not supported

Login to reply

👍?
helpful
4:56pm Sun 18th Sep, Christopher M.

ANONYMOUS wrote:
> Ah thanks for clarifying; then it'll fail at the array initialization. 👍
Yes, though it's the array *definition*. It is not initialised.

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  1:17AM Sep 14 2022
Privacy policy