5 Replies - 6600 Views - Last Post: 16 December 2012 - 03:25 AM Rate Topic: -----

#1 isuru~  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 16-December 12

Question in Declaring and using arrays in writing pseudocode

Posted 16 December 2012 - 02:16 AM

Can I use
 int mArray[]={1,2,3,4,5}
to declare an array when writing pseudo code?
Is This A Good Question/Topic? 0
  • +

Replies To: Question in Declaring and using arrays in writing pseudocode

#2 AKMafia001  Icon User is offline

  • </code.in.dream>

Reputation: 187
  • View blog
  • Posts: 624
  • Joined: 11-June 11

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,
// 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

Was This Post Helpful? 1
  • +
  • -

#3 isuru~  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 16-December 12

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??
Was This Post Helpful? 0
  • +
  • -

#4 isuru~  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 16-December 12

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}
???
Was This Post Helpful? 0
  • +
  • -

#5 sepp2k  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2089
  • View blog
  • Posts: 3,181
  • Joined: 21-June 11

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.
Was This Post Helpful? 1
  • +
  • -

#6 AKMafia001  Icon User is offline

  • </code.in.dream>

Reputation: 187
  • View blog
  • Posts: 624
  • Joined: 11-June 11

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...

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!
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1