Programming: what's wrong with my C# code?

User Generated

fryvfr

Programming

Description

I need to write a while loop that print all odd numbers 1-21 separated by spaces, with no new lines. My output is coming up blank. What's wrong with my code?

class Program

{

static void Main(string[] args)

{

{

int i = 0;

while (i <= 21)

if

(i % 2 == 1);

{

Console.WriteLine(i);

                    i ++;//add increment control variable

}

}

}

}

}


User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer


Anonymous
Just what I needed. Studypool is a lifesaver!

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Similar Content

Related Tags