Skip to content
Snippets Groups Projects
Commit 7fc8822c authored by Vesa Lappalainen's avatar Vesa Lappalainen :bicyclist:
Browse files

MuuttujaEsim

parent 8f7fd818
No related branches found
No related tags found
No related merge requests found
/// @author Vesa Lappalainen
/// @version 18.09.2011
///
/// <summary>
/// Esimerkkejä muuttujista
/// </summary>
public class MuuttujatTesti
{
public static void Main(string[] args)
{
int a = 5 + 6;
System.Console.WriteLine(a); // 11
a++; // a = a + 1;
System.Console.WriteLine(a); // 12
System.Console.WriteLine(a++); // 12
System.Console.WriteLine(++a); // 14
// -- vähentämiseen
// +=, -=, *=, /=, %=
int b = 7 % 3; // jj 1
b += 3; // b:n arvo tämän rivin jälkeen on 4
System.Console.WriteLine(b); // 4
int c = 57831 % 2;
System.Console.WriteLine(c); // 1
int d = 5 + 10 % 6 / 3 + 1; // 7.333 --> 7
System.Console.WriteLine(d); // 7
// ReSharper disable once PossibleLossOfFraction
double e = 5.0 + 10 % 6 / 3 + 1;
System.Console.WriteLine(e); // 7
// Miksi kymppiin ei tarvi pistää välttämättä pisteitä
// koska 10 % 6.0 palautta 4.0
double f = 5.0 + 10 % 6.0 / 3.0 + 1;
System.Console.WriteLine(f); // 7.333333333333333
double g = 5.0 + 9 % 7.0 / 2 + 1;
System.Console.WriteLine(g); // 7
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ExternalConsole>true</ExternalConsole>
</PropertyGroup>
</Project>
......@@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LumiukkoVoima", "LumiukkoVo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FunktioitaNc", "FunktioitaNc\FunktioitaNc.csproj", "{68F46C3A-D7A8-4A54-B8CF-A12D0B3E9463}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MuuttujatEsim", "MuuttujatEsim\MuuttujatEsim.csproj", "{3A774F25-0315-441C-A54B-48B7D079E33D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -43,5 +45,9 @@ Global
{68F46C3A-D7A8-4A54-B8CF-A12D0B3E9463}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68F46C3A-D7A8-4A54-B8CF-A12D0B3E9463}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68F46C3A-D7A8-4A54-B8CF-A12D0B3E9463}.Release|Any CPU.Build.0 = Release|Any CPU
{3A774F25-0315-441C-A54B-48B7D079E33D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A774F25-0315-441C-A54B-48B7D079E33D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A774F25-0315-441C-A54B-48B7D079E33D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A774F25-0315-441C-A54B-48B7D079E33D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment