Sign in to follow this  
Followers 0
Jellyicex

Pseudo code

3 posts in this topic

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

Share this post


Link to post
Share on other sites

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.

1 person likes this

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.