• 0

Question

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
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

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.

Link to comment
Share on other sites

  • 0

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.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.