Challenge: Comments
The following program prints numbers from 1 to 10. Comment out the lines that print odd numbers.
Note
Use single-line comments to solve this task.
main.cs
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
namespace TestConsoleApp
{
internal class Program
{
static void Main(string[] args)
{
System.Console.WriteLine(1);
System.Console.WriteLine(2);
System.Console.WriteLine(3);
System.Console.WriteLine(4);
System.Console.WriteLine(5);
System.Console.WriteLine(6);
System.Console.WriteLine(7);
System.Console.WriteLine(8);
System.Console.WriteLine(9);
System.Console.WriteLine(10);
}
}
}
12345678910111213141516171819namespace TestConsoleApp { internal class Program { static void Main(string[] args) { System.Console.WriteLine(1); System.Console.WriteLine(2); System.Console.WriteLine(3); System.Console.WriteLine(4); System.Console.WriteLine(5); System.Console.WriteLine(6); System.Console.WriteLine(7); System.Console.WriteLine(8); System.Console.WriteLine(9); System.Console.WriteLine(10); } } }
Single-Line comments can be added using double-slash (
//
);Even numbers are those which can be divided into two equal parts or in other words those numbers which are divisible by 2. For-example: 2, 4, 6 etc. Odd numbers are the opposite of even numbers for-example: 1, 3, 5 etc.
main.cs
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
namespace TestConsoleApp
{
internal class Program
{
static void Main(string[] args)
{
// System.Console.WriteLine(1);
System.Console.WriteLine(2);
// System.Console.WriteLine(3);
System.Console.WriteLine(4);
// System.Console.WriteLine(5);
System.Console.WriteLine(6);
// System.Console.WriteLine(7);
System.Console.WriteLine(8);
// System.Console.WriteLine(9);
System.Console.WriteLine(10);
}
}
}
12345678910111213141516171819namespace TestConsoleApp { internal class Program { static void Main(string[] args) { // System.Console.WriteLine(1); System.Console.WriteLine(2); // System.Console.WriteLine(3); System.Console.WriteLine(4); // System.Console.WriteLine(5); System.Console.WriteLine(6); // System.Console.WriteLine(7); System.Console.WriteLine(8); // System.Console.WriteLine(9); System.Console.WriteLine(10); } } }
Var alt klart?
Tak for dine kommentarer!
Sektion 1. Kapitel 6
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat