Browse Source

my solution

Has many comments.
master
Wágner András 1 year ago
parent
commit
0a47dcb6c1
  1. 47
      Program.cs

47
Program.cs

@ -1,7 +1,40 @@
using System;
class Program {
static void Main(string[] args) {
// Your code goes here
}
}
using System;
namespace Csharp
{
class Program
{
static void Main(string[] args)
{
//declaring variables
int n = 2;
int m = 3;
string foo = "foo";
string bar = "bar";
//1. sum, difference and product
Console.WriteLine(n+m);
if(n-m>0){ //the difference is always a positive number
Console.WriteLine(n-m);
}else{
Console.WriteLine(m-n);
}
/*
If the difference is 0,
it doesn't matter wihch way we subtruct.
*/
Console.WriteLine(n*m);
//2. strings one by one and in both orders
Console.WriteLine(foo);
Console.WriteLine(bar);
Console.WriteLine(foo+bar); //note that strings can be added to strings.
Console.WriteLine(bar+foo);
/*
Console.WriteLine() automatically displays output in separate lines.
Console.Write() would not do this.
*/
Console.ReadLine(); //Keeps terminal open until 'Enter' is hit.
}
}
Loading…
Cancel
Save