Jump to content



Photo

Pseudo code

this is driving me nuts

  • Please log in to reply
2 replies to this topic

#1 Jellyicex

Jellyicex

    Neowinian

  • Joined: 22-October 13

Posted 22 October 2013 - 23:39

Hey guys, I'm pretty new to programming (started course just a few weeks ago) and I've hit a brick wall and I don't know how to bypass it. For an assignment I've been tasked to produce an array and populate it without having 5 individual statements that assign the 5 elements one by one, and I have to use a FOR loop all in pseudo code. I have to assign 10, 20, 30, 40 and 50 to the array. Sorry if this sounds so basic for you guys, I'm such a newb at this.

 

:/  So here's my latest attempt:

 

 

display "How many numbers do you want to store?"
get storage
declare numbers[storage]
for count = 0 to storage-1
get numbers[count]
endfor
 
display "The numbers you entered were"
for count = 0 to storage-1
display numbers[count]
endfor
 
I know it isn't correct because whenever I test it out in the Uni's interpreter it says that my array should be 5 in length and that the elements are undefined. I need to define the elements without tampering with them individually, I just can't figure it out. I've been looking around for some hints and tips but can't find any.
 
Could someone please help me out? I'd greatly appreciate some guidance with this  :cry:
 
Thanks



#2 Andre S.

Andre S.

    Asik

  • Tech Issues Solved: 11
  • Joined: 26-October 05

Posted 23 October 2013 - 00:06

It looks like this isn't really pseudocode but a custom programming language used at your university. You must find what is the proper syntax in that language to declare an array.

 

One possibility is that you cannot create an array of a dynamic size, and that instead of getting the number of elements from the user and using that variable to initialize the array, you should just hardcode 5 in there. I don't know what restrictions this language imposes.



#3 OP Jellyicex

Jellyicex

    Neowinian

  • Joined: 22-October 13

Posted 23 October 2013 - 08:04

It looks like this isn't really pseudocode but a custom programming language used at your university. You must find what is the proper syntax in that language to declare an array.

 

One possibility is that you cannot create an array of a dynamic size, and that instead of getting the number of elements from the user and using that variable to initialize the array, you should just hardcode 5 in there. I don't know what restrictions this language imposes.

Yeah, I had a feeling that it would turn out to be a custom programming language used at my university :( . Thanks for the help though, I'll see what I can do.