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 selected article
Showing 1 of 828 articles.
Currently 76 other people reading this forum.


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

Login to reply

👍?
helpful
5:05pm Mon 9th Sep, Harrison L.

Hello,

This makes sense, but what if the variable is used again outside of the scope of the function?

function func a
	problem <- 3
	return a + problem
problem <- 5
print func(problem)

The above example would work with a result of 8, with problem being a variable inside and outside of the scope of func- in fact, even the following should work:

function func a
	problem <- 3
	return a + problem
print func(problem)

With a result of 3- as problem would be automatically instated as a variable with the value of 0:

variables do not need to be defined before being used in an expression, and are automatically initialised to the (real) value 0.0

So- am I correct in assuming that in both of the above scenarios, problem counts as 2 identifiers?

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