Line | |
---|
1 | using System; |
---|
2 | using System.Text; |
---|
3 | using System.Linq; |
---|
4 | using System.Collections.Generic; |
---|
5 | |
---|
6 | /// @author Antti-Jussi Lakanen |
---|
7 | /// @version 21.1.2015 |
---|
8 | /// |
---|
9 | /// <summary> |
---|
10 | /// Muuttujien ja operaattorien kokeilua. |
---|
11 | /// </summary> |
---|
12 | public class MuuttujatTesti |
---|
13 | { |
---|
14 | /// <summary> |
---|
15 | /// Kokeillaan eri operaattoreita ja tutkitaan |
---|
16 | /// eri tyyppejä. |
---|
17 | /// </summary> |
---|
18 | public static void Main() |
---|
19 | { |
---|
20 | int a = 3 + 5 - 1 / 2; |
---|
21 | Console.WriteLine(a); |
---|
22 | |
---|
23 | int b = 5 % 3; // modulo-operaattori, tulos 2 |
---|
24 | Console.WriteLine(b); |
---|
25 | |
---|
26 | int c = b * 2; // mitä tapahtuu tässä b:lle? |
---|
27 | Console.WriteLine("b:n arvo nyt: " + b); |
---|
28 | Console.WriteLine("c:n arvo nyt: " + c); // 4 |
---|
29 | |
---|
30 | c++; |
---|
31 | Console.WriteLine(c); // 5 |
---|
32 | |
---|
33 | c = c + 1; |
---|
34 | |
---|
35 | Console.WriteLine(c); // 6 |
---|
36 | Console.WriteLine(c + 1); // mitä tulostuu? Mitä on c:n arvo? |
---|
37 | Console.WriteLine(c); |
---|
38 | |
---|
39 | Console.WriteLine("7 % 7 on " + 7 % 7); |
---|
40 | |
---|
41 | Console.WriteLine("8-7%7 on " + (8 - (7 % 7))); |
---|
42 | |
---|
43 | Console.WriteLine(3 / 2); |
---|
44 | |
---|
45 | double jakolasku = 3 / 2; |
---|
46 | Console.WriteLine("jakolaskun arvo on: " + jakolasku); // mitä tulostuu? |
---|
47 | |
---|
48 | jakolasku = jakolasku * 2; // jakolasku *= 2; |
---|
49 | |
---|
50 | Console.WriteLine(jakolasku); // mitä tulostuu? |
---|
51 | |
---|
52 | Console.ReadKey(); |
---|
53 | } |
---|
54 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.