Sunday, December 13, 2015

online code tool

ideone.com (click to try)

Ideone is an online compiler and debugging tool which allows you to compile source code and execute it online in more than 60 programming languages.

Advices

You can code.  They cannot.  That is cool.

1. Read Some Code

visit https://github.com/

search quiz, blog or others project to read c# code

2. Functions

IN:
using System;

public class Test
{
     public static void Main()
     {
          WriteWorld();
     }

     static void WriteWorld()
     {
          Console.WriteLine("Hello World!");
     }
}

OUT:
Hello World!

3. While Loops

IN:
using System;

public class Test
{
public static void Main()
{
int n;
while ((n = int.Parse(Console.ReadLine()))!=42)
Console.WriteLine(n);
}
}

OUT:
1
2
10

4. Loops And Arrays

IN:
using System;

public class Test
{
     public static void Main()
     {
          int[] n = new int[6];
  n[0] = 60; n[1] = 70; n[2] = 80;
  n[3] = 90; n[4] = 90; n[5] = 90;

  int i, sum=0;
  for (i = 0; i < 6; i++)
  sum += n[i];
  Console.WriteLine(sum);
     }
}

OUT:
480

5. What If

IN:
using System;

public class Test
{
     public static void Main()
     {
          int n;
          if ((n = int.Parse(Console.ReadLine())) != 42);
              Console.WriteLine(n);
     }
}

OUT:
1

Wednesday, December 9, 2015

6. Asking Questions

IN:
using System;

public class Test
{
     public static void Main()
     {
           string s;
          Console.WriteLine("How old are you?");
          s = Console.ReadLine();
          Console.WriteLine("So, you are "+ s +" old.");
     }
}

OUT:
So, you are 23 old.

7. Variables and Names

IN:
using System;

public class Test
{
     public static void Main()
     {
           int cars, drivers, cars_not_driven;
           cars = 100;
           drivers = 30;
           cars_not_driven = cars - drivers;
          Console.WriteLine("There will be " + cars_not_driven + " empty cars today.");
     }
}

OUT:
 There will be 70 empty cars today.

Tuesday, December 8, 2015

8. Numbers and Math

IN:
using System;

public class Test
{
     public static void Main()
     {
          Console.WriteLine(26 + 30 / 5);
     }
}

OUT:
32

9. Comments

IN:
using System;

public class Test
{
     public static void Main()
     {
          // Console.WriteLine("This won't run.");
          Console.WriteLine("This will run.");
     }
}

OUT:
This will run.

10. Hello World!

IN:
using System;

public class Test
{
     public static void Main()
     {
          Console.WriteLine("Hello World!");
     }
}

OUT:
Hello World!

Friday, December 4, 2015