tisdag 2 oktober 2012

Print a table with number from 1 to 100 in C#

This snippet will print a short table with number from 1 to 100,
Using the if-statement if (i % 10 == 0) what it does is that it check it we can divide variable  i with 10.

If true it will print using Console.WriteLine( i +  " "); Writeline makes it start on a new line.
But if not true it will print Console.Write(i+ " "); the diffrent between that is that it will not start on a new line.

A last notice is that we have Console.ReadKey(); to prevent the program from closing right after  it's done with printing.

Pastebin http://adf.ly/DMWcC Have a nice day.

Inga kommentarer:

Skicka en kommentar