# In class pseudocode Q!



## Viscarious (Feb 17, 2009)

Ok, so Im pretty new into programming but I'm almost done with this semester. However, Ive got this problem in my book and its stumping me. 

"Design a nested loop that displays 10 rows of # characters. There should be  15 # characters in each row."

Alright, so its asking for nested for loops with 15 digits but only 10 rows. Ive got this much so far:

Declare Integer numOne, numTwo, numThree

For numOne = 10000 to 10004

	For numTwo = 10005 to 10009

		For numThree = 10010 to 10014

			Display numOne, numTwo, numThree

		End For

	End For

End For


(the forums wont let me use tabs on the program so please beware that that part of the code is messed up)

Its not ment to do anything but I cant think of anything that could fit this scenario. Thoughts and helpful criticism much appreciated.


----------



## a111087 (Feb 17, 2009)

ha, i understood instructions a bit differently
you just need this:
#####...15of these...#######
#####...15of these...#######
#####...15of these...#######
...10 rows...
#####...15of these...#######
#####...15of these...#######
#####...15of these...#######

I'm probably wrong



EDIT#2:  (Sorry, 10 ROWS, not 15  )
And by the way, you loops will execute 25 times (5*5*5), while you need 10 (5*2)
So, if you want to keep your code then do this:

Declare Integer numOne, numTwo, numThree
numThree = 10010
For numOne = 10000 to 10004
For numTwo = 10005 to 10006
Display numOne, numTwo, numThree
End For
End For


----------



## Viscarious (Feb 17, 2009)

lol, I wish it was that easy.

I dont see the point to taking programming for the IT field...

Also, I must qoute the arbiter from Halo here.

"Were it so easy."


----------



## mdm-adph (Feb 17, 2009)

How about:

X = 1
LOOP UNTIL X = 10
[
Y = 1
LOOP UNTIL Y = 15
[
PRINT "#"
Y = Y + 1
]
X = X + 1
]


----------



## Viscarious (Feb 17, 2009)

a111087 said:


> ha, i understood instructions a bit differently
> you just need this:
> #####...15of these...#######
> #####...15of these...#######
> ...



Hmm, this doesnt look too bad. I'll try this in raptor and see how it compiles. Thanks!



mdm-adph said:


> How about:
> 
> X = 1
> LOOP UNTIL X = 10
> ...



I havnt seen anything like this yet in my class. Fascinating though. Thank you!


----------



## mdm-adph (Feb 17, 2009)

Viscarious said:


> I havnt seen anything like this yet in my class. Fascinating though. Thank you!



Well, as I recall, in my day "pseudocode" just meant "crap code used to explain something."  

Is your class teaching you a specific language?


----------



## Viscarious (Feb 17, 2009)

mdm-adph said:


> Well, as I recall, in my day "pseudocode" just meant "crap code used to explain something."
> 
> Is your class teaching you a specific language?



Haha, yea, its pretty much just psudocode. Its being taught in a perticular way though, as you can see from the way I define variables and whatnot. Its still only meant to explain what is going on before writing the actual code in whichever language I choose.


----------



## Viscarious (Feb 17, 2009)

Finished product and correct answer:

Declare String C = “###############”
		For X = 1 to 10
			For Y = 1 to 15
				If Y = 15 Then
					Display C
				End If
			End For
		End For



Thanks again fellas for the help!


----------



## W1zzard (Feb 17, 2009)

while your code above works fine and fulfills what was asked of you, your teacher wanted to see. the \n is a newline character which does the same as pressing enter in a word processor


```
for (int i=0; i<10; i++)
{
  for (int j=0; j<15; j++)
  {
    printf("#");
  }
  printf("\n");
}
```


----------



## a111087 (Feb 17, 2009)

that is such a waist of processor time 
it loops 14 times before anything is done, but oh well, "it works" said Gothic 3 developer lol


----------



## FordGT90Concept (Feb 17, 2009)

Viscarious said:


> "Design a nested loop that displays 10 rows of # characters. There should be  15 # characters in each row."




```
for (byte rownum = 0; rownum < 10; rownum++)
{
  for (byte colnum = 0; colnum < 15; colnum++)
  {
     // Output
  } 
}
```

This looks like code for working with strings...


Oops, it's already been answered.


You're making a grid of 10x15 so the innermost nested code should run 150 times.


----------



## W1zzard (Feb 17, 2009)

a111087 said:


> that is such a waist of processor time
> it loops 14 times before anything is done



uh, no (if you are referring to my sample)


----------



## a111087 (Feb 17, 2009)

no, i was talking about Viscariou's final code


----------



## Viscarious (Feb 17, 2009)

Well, its waht the teach said was correct. So, I wrote it down and added and buncha notes with you guy's comments and your pseudocode. Again, thank you all for the awesome-o 5000 help! I know I can count on TPU!


----------

