-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtutorial2.cs
92 lines (75 loc) · 2.43 KB
/
tutorial2.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using System;
namespace tutorial2
{
class Program
{
static void Main(string[] args)
{
//Loops
//while loop
/*Console.WriteLine("Please enter your target?");
int UserTarget = int.Parse(Console.ReadLine());
int start = 0;
while (start <= UserTarget)
{
Console.Write(start+" ");
start += 1;
}
// Console.WriteLine("Please enter your target?");
// int UserTarget = int.Parse(Console.ReadLine());
//USE DO WHILE LOOPS INSTEAD OF GOTO STATEMENTS
string UserChoice = string.Empty;
do
{
Console.WriteLine("Please enter your target?");
int UserTarget = int.Parse(Console.ReadLine());
int start = 0;
while (start <= UserTarget)
{
Console.Write(start + " ");
start = start + 2;
}
do
{
Console.WriteLine("Do you want continue - Yes or No?");
UserChoice = Console.ReadLine().ToUpper();
if (UserChoice != "YES" && UserChoice != "NO")
{
Console.WriteLine("Invalid Choice, please say Yes or No");
}
} while (UserChoice != "YES" && UserChoice != "NO");
} while (UserChoice == "YES");*/
/*int[] numbers = new int[3];
numbers[0] = 101;
numbers[1] = 102;
numbers[2] = 103;
for (int j = 0; j<numbers.Length;j++)
{
Console.WriteLine(numbers[j]);
}
Console.WriteLine("\n");
int i = 0;
while (i <numbers.Length)
{
Console.WriteLine(numbers[i]);
i++;
}
Console.WriteLine("\n");
//No out of bound Exception with a foreach
foreach (int itm in numbers)
{
Console.WriteLine(itm);
}
*/
//break and continue
for (int i = 0; i <= 20; i++)
{
if (i % 2 == 1)
continue;
Console.WriteLine(i);
if (i == 10)
break;
}
}
}
}