how do i display the following:
Q1)1 Q2)1AAAA
00 12BBB
111 123CC
0000 1234D
11111
how do i display the following:
Q1)1 Q2)1AAAA
00 12BBB
111 123CC
0000 1234D
11111
MessageBox.Show("Q1)1 Q2)1AAAA 00 12BBB 111 123CC 0000 1234D 11111")
Please explain what you need the loop(s) to do. Also please show your code so far so we can help.
EDIT
Ok the various output lines make more sense now in your question. However it would still be useful and recommended to post your code thus far, so we can help point you in the right direction.
(Glad to help but aren't here to write everything for you.)
Q1:
Q2:
Pseudo-code only, since this smells suspiciously like homework :-)
Number 1:
string s1, s2 or shifty version: string s
integer i, j integer i,j,k
s1 = "1" k = 0
for i = 1 to 5 for i = 1 to 5
s2 = "" s = ""
for j = 1 to i for j = 1 to i
s2 = s2 + s1 s = s + chr(k+30)
endfor endfor
output s2 output s
if s1 = "1" then k = 1 - k
s1 = "0" endfor
else
s1 = "1"
endif
endfor
Number 2:
string s
integer i, j
for i = 1 to 4
s = ""
for j = 1 to i
s = s + chr(j+30)
endfor
for j = i+1 to 5
s = s + chr(i+64)
endfor
output s
endfor
No need for inner and outer loop. This will do it:
Q1:
For p As Integer = 1 To 5
MsgBox("".PadRight(p, CChar((p Mod 2).ToString)))
Next
Q2:
Dim pre As String = ""
For p As Integer = 0 To 3
pre &= (p + 1).ToString
MsgBox(pre & "".PadRight(4 - p, CChar(Chr(65 + p))))
Next
PS. Please tell us your teachers reaction to "your" solution. ;)