0

How can I repeat this using the 'for' loop? (Please read the description)

I want to repeat this alphabet: Β,Β,D,D, F,F,…….Z,Z using the 'for' loop. Can someone please explain me how to do this?

23rd Dec 2021, 2:25 PM
Eveft03
Eveft03 - avatar
5 Respuestas
+ 3
My idea is to have a char variable, let's name it <c>. Next, assign 'B' to it, then you setup the for loop; condition is while <c> <= 'Z'. In loop body you print <c> twice with a comma in between. You need to increment <c> by 2.
23rd Dec 2021, 3:16 PM
Ipang
+ 2
I did it! Thank you very much for helping me!
23rd Dec 2021, 3:29 PM
Eveft03
Eveft03 - avatar
+ 2
I'm glad you made it! 👍
23rd Dec 2021, 3:29 PM
Ipang
+ 1
Only those characters? What defines the range? as we can see it started with 'B' and ended with 'Z' An output example (as you expected it to be) may help others to understand.
23rd Dec 2021, 2:57 PM
Ipang
0
The output should look like this: B,B, D,D, F,F, H,H, J,J, L,L, N,N, P,P, R,R, T,T, V,V, X,X, Z,Z
23rd Dec 2021, 3:09 PM
Eveft03
Eveft03 - avatar