+ 1

Please How do u write a code that Prints 100 members of the sequence 2, -3, 4, -5, 6, -7, 8 in C#.

I know it's using for loop, but don't know the right syntax to use

21st Jun 2019, 12:07 PM
ogba japhet
ogba japhet - avatar
2 odpowiedzi
+ 8
Run a loop from 2 to n, and you can use % operator to decide - sign print(n%2!=0 ? "-" : "")
21st Jun 2019, 1:42 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 2
you can use 2 loops one that prints the even number and the other that add -2 to that with <50 condition
21st Jun 2019, 12:17 PM
✳AsterisK✳
✳AsterisK✳ - avatar