Skip to content

Commit 9c7b5ae

Browse files
authored
Update Program.cs
1 parent 70ddf89 commit 9c7b5ae

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

source-code-EXPLAINED/Program.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//auto-generated code start
1+
//auto-generated code start
22
using System;
33
using System.Collections.Generic;
44
using System.Linq;
@@ -49,16 +49,22 @@ static void Main(string[] args)
4949
Console.ReadKey();//waits for user key (enter, space...)
5050
return;//it stops the program process
5151
}
52-
Console.BackgroundColor = ConsoleColor.DarkCyan; //changes font color
53-
Console.WriteLine(a);//writes the number you typed
54-
Console.BackgroundColor = ConsoleColor.Black; //resets font color
52+
5553
// - THE MOST IMPORTANT PART IN THE CODE -
5654
// --------------------------------------------------
5755
//for cycle which prints the number backwards until 0:
58-
// 1) We declare the long b which is a - 1, suppose we typed the number 10, b will be 10 - 1
56+
// 1) We declare the long b which is equal to a, suppose we typed the number 10, long b will be 10
5957
// 2) We declare when the program stops, in this case it will stop when b will be minor or equal to a (never), so we created an infinite loop
6058
// 3) We declare what the program must do when it's in the cycle, in this case every time the cycle restarts it will subtract 1 to long b
61-
for (long b = a - 1; b <= a; b--)
59+
// PS: We can also use:
60+
// while (true) {
61+
//
62+
// if (b == 0) {
63+
// ...
64+
// replace return; with break;
65+
// }
66+
// }
67+
for (long b = a; b <= a; b--)
6268
{
6369

6470
if (b == 0)
@@ -87,4 +93,4 @@ static void Main(string[] args)
8793
//▒█▄▄█ ▒█▒█▒█   ▒█░ ░▒█░░ ▒█▄▄█ ▒█░░░ ▒█░ ▒█▄▄█ ▒█▒█▒█   ▒█▄▄█ ▒█▄▄▀ ▒█░░▒█ ▒█░▄▄ ▒█▄▄▀ ▒█▄▄█ ▒█▒█▒█
8894
//▒█░▒█ ▒█░░▀█   ▄█▄ ░▒█░░ ▒█░▒█ ▒█▄▄█ ▄█▄ ▒█░▒█ ▒█░░▀█   ▒█░░░ ▒█░▒█ ▒█▄▄▄█ ▒█▄▄█ ▒█░▒█ ▒█░▒█ ▒█░░▒█
8995

90-
//-----------------------------------------------------------------------------------------------------//
96+
//-----------------------------------------------------------------------------------------------------//

0 commit comments

Comments
 (0)