Write a program that prints the first 100 members of the sequence 2,-3,4,-5,6,-7,8.
Can anyone provide me with the code of this program?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pankaj Kumar ChoudharyPosted Jul 2, 2015, 5:15 PM
{
int i = 0;
while (i < 100)
{
Console.WriteLine((i+2)%2==0?(i+2).ToString():((-(i+2)).ToString()));
i++;
}
Console.ReadLine();
}
Rahul PrajapatPosted Jul 2, 2015, 10:21 PM
{
Console.Write(((i % 2) == 0 ? i.ToString() : (-i).ToString()) + ",");
}
Thavaselvan PalanivelPosted Jul 2, 2015, 1:58 PM