Discussion:
-- A5 --
(too old to reply)
Pritesh Bodalia
2004-07-11 00:52:32 UTC
Permalink
1) The assignment states that "The phases must be completed in order",
since looping is easier to implement, can that come before arrays?

2) Is boolean input required?
ex. bool x;
x <-- in();

3) Any tips for allocating space for dynamically sized arrays ?
Troy Mark Gonsalves
2004-07-12 15:22:26 UTC
Permalink
Post by Pritesh Bodalia
1) The assignment states that "The phases must be completed in order",
since looping is easier to implement, can that come before arrays?
Yes. Some phases are dependent on previous phases, but your free to do the
bonus in any order. I expect that many of you will do the recursion and
the looping bonus...Only a few will try for the array bonuses.
Post by Pritesh Bodalia
2) Is boolean input required?
ex. bool x;
x <-- in();
Yes.
Post by Pritesh Bodalia
3) Any tips for allocating space for dynamically sized arrays ?
First off, here is the only way to get a dynamic array:

void a ( int x )
begin
int b[x];
end;

Dealing with this is not that hard. Just compute the expression and
allocate space on the stack...Unless you done something tricky, I don't
think the code is any different than handling:
begin
int b[1+3+5];
end;

...but I haven't got around to the array bonus yet.
Darryl Tam
2004-07-12 16:42:10 UTC
Permalink
Post by Pritesh Bodalia
2) Is boolean input required?
ex. bool x;
x <-- in();
Yes.
In the CS241 newsgroup, Chris Ingram indicated that "There is no "in" for
booleans." (Posting Jul 10 8:29PM). Can I get a clarification?
Troy Mark Gonsalves
2004-07-15 18:31:15 UTC
Permalink
I'm sticking with my answer.

But you don't have to verify that the values
the user types are 1 or 0....That should make things simple enough.
Post by Darryl Tam
Post by Pritesh Bodalia
2) Is boolean input required?
ex. bool x;
x <-- in();
Yes.
In the CS241 newsgroup, Chris Ingram indicated that "There is no "in" for
booleans." (Posting Jul 10 8:29PM). Can I get a clarification?
Stephen Tse
2004-07-12 19:40:00 UTC
Permalink
I was under the impression that input can only take a decimal input and a
single character as the specs state.

"Execution of the statement consists of reading either a number expressed
in decimal or a character from the standard input stream and storing it in
the specified variable."

Unless you want to treat 1s and 0s as true/false values, it seems like you
cannot input a boolean.

Stephen Tse
Post by Troy Mark Gonsalves
Post by Pritesh Bodalia
1) The assignment states that "The phases must be completed in order",
since looping is easier to implement, can that come before arrays?
Yes. Some phases are dependent on previous phases, but your free to do the
bonus in any order. I expect that many of you will do the recursion and
the looping bonus...Only a few will try for the array bonuses.
Post by Pritesh Bodalia
2) Is boolean input required?
ex. bool x;
x <-- in();
Yes.
Post by Pritesh Bodalia
3) Any tips for allocating space for dynamically sized arrays ?
void a ( int x )
begin
int b[x];
end;
Dealing with this is not that hard. Just compute the expression and
allocate space on the stack...Unless you done something tricky, I don't
begin
int b[1+3+5];
end;
...but I haven't got around to the array bonus yet.
Troy Mark Gonsalves
2004-07-15 18:32:26 UTC
Permalink
We already treat true and false as 1 and 0 for output...I see no problem
with doing the same for input.
Post by Stephen Tse
I was under the impression that input can only take a decimal input and a
single character as the specs state.
"Execution of the statement consists of reading either a number expressed
in decimal or a character from the standard input stream and storing it in
the specified variable."
Unless you want to treat 1s and 0s as true/false values, it seems like you
cannot input a boolean.
Stephen Tse
Post by Troy Mark Gonsalves
Post by Pritesh Bodalia
1) The assignment states that "The phases must be completed in order",
since looping is easier to implement, can that come before arrays?
Yes. Some phases are dependent on previous phases, but your free to do the
bonus in any order. I expect that many of you will do the recursion and
the looping bonus...Only a few will try for the array bonuses.
Post by Pritesh Bodalia
2) Is boolean input required?
ex. bool x;
x <-- in();
Yes.
Post by Pritesh Bodalia
3) Any tips for allocating space for dynamically sized arrays ?
void a ( int x )
begin
int b[x];
end;
Dealing with this is not that hard. Just compute the expression and
allocate space on the stack...Unless you done something tricky, I don't
begin
int b[1+3+5];
end;
...but I haven't got around to the array bonus yet.
Continue reading on narkive:
Loading...