int mArray[]={1,2,3,4,5}
to declare an array when writing pseudo code?
5 Replies - 804 Views - Last Post: 16 December 2012 - 03:25 AM
#1
Question in Declaring and using arrays in writing pseudocode
Posted 16 December 2012 - 02:16 AM
Can I use
Replies To: Question in Declaring and using arrays in writing pseudocode
#2
Re: Question in Declaring and using arrays in writing pseudocode
Posted 16 December 2012 - 02:44 AM
Well! That would be a less pseudo-code and a more C/C++ statement...
I would do it somehow like this,
Hope this Helps!
I would do it somehow like this,
// Declarations
Constant Integer SIZE = 5
Declare Integer mArray[SIZE]
Declare Integer index
// loop through the array and fill it
For index = 0 to 4
Set mArray[index] = index + 1
End For
// Print the contents of the array
For index 0 to 4
print mArray[index]
End For
Hope this Helps!
This post has been edited by AKMafia001: 16 December 2012 - 02:46 AM
#3
Re: Question in Declaring and using arrays in writing pseudocode
Posted 16 December 2012 - 03:03 AM
Thanks. That explains a lot. But syill I need to get this cleared. What if I needed some values such as 1,8,9 with no order in that array> Do I have to assign each of them one by one??
#4
Re: Question in Declaring and using arrays in writing pseudocode
Posted 16 December 2012 - 03:09 AM
I mean if I wanted something like
myArray[]={21,54,78}
???
#5
Re: Question in Declaring and using arrays in writing pseudocode
Posted 16 December 2012 - 03:24 AM
It's pseudo code. Just write it in any way that your reader will understand. myArray = {item1, item2, ...} seems perfectly fine to me (though personally I wouldn't bother with types in pseudo code).
PS: AKMafia's syntax seems needlessly verbose to me. I wouldn't go that way.
PS: AKMafia's syntax seems needlessly verbose to me. I wouldn't go that way.
#6
Re: Question in Declaring and using arrays in writing pseudocode
Posted 16 December 2012 - 03:25 AM
Well! You know its pseudo-code, just try what looks good to you...
Or even you can do it like this too,
Anything that suits you...
Hope this Helps!
Set mArray[0] = 21 Set mArray[1] = 54 Set mArray[2] = 78
Or even you can do it like this too,
Constant Integer SIZE = 3 Define Integer mArray[SIZE] = 21, 54, 78 // Or Integer mArray[] = 21, 54, 78
Anything that suits you...
Hope this Helps!
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|