0
how print this pattern 2 24 246 2468 246810
using for loop in c
5 Respuestas
+ 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.
+ 3
Please tag 'C-language' - the language relevant to your question; not just 'help'
https://code.sololearn.com/W3uiji9X28C1/?ref=app
+ 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.
+ 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
0
2
24
246
2468
246810