how print this pattern 2 24 246 2468 246810 | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

how print this pattern 2 24 246 2468 246810

using for loop in c

11th Apr 2023, 6:19 PM
rahman Ansil
rahman Ansil - avatar
4 Respostas
+ 8
rahman Ansil Use two nested loop which the outer is responsible to print a space and increments a variable that specify the length each element in pattern. But the inner loop will build the value of each element in pattern.
11th Apr 2023, 6:32 PM
Yasin Rahnaward
Yasin Rahnaward - avatar
+ 3
Please tag 'C-language' - the language relevant to your question; not just 'help' https://code.sololearn.com/W3uiji9X28C1/?ref=app
11th Apr 2023, 8:12 PM
Ipang
+ 3
You have to print each time the product of 2*x where x will be a variable with start value equal to 1. After each iteration you have to increment x by 1 (x=x+1;). Thus, at first iteration it will be printed 2, at second 24, etc. In the end of each print don't forget to set x=1 again. You have to use two for loops, one for the number of prints and one for the prints.
11th Apr 2023, 10:36 PM
Black Winter
+ 1
Not sure about the c syntax. Just take this as pseudo code. next=current%10+2 current = (current.toStr+next. toStr).toInt You can pass that logic into a loop or recursive function to get each element of the pattern you're looking for
12th Apr 2023, 12:14 AM
Bob