Friday, April 29, 2016

Collection of String and Float

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Collection_2
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> names = new List<string>();
            List<float> scores = new List<float>();
            names.Add("Dara");
            scores.Add(90);
            names.Add("Kunthear");
            scores.Add(95.5f);
            names.Add("Veasna");
            scores.Add(70);
            names.Add("Sambo");
            scores.Add(100);
            names.Add("Bopha");
            scores.Add(80);
            for (int i = 0; i < names.Count; i++)
                Console.WriteLine(names[i] + "," + scores[i]);
            Console.ReadLine();
        }
    }
}

Collection of String

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Collection_1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> names = new List<string>();
            names.Add("Dara");
            names.Add("Kunthear");
            names.Add("Veasna");
            names.Add("Sambo");
            names.Add("Bopha");
            for (int i = 0; i < names.Count; i++)
                Console.WriteLine(names[i]);
            Console.ReadLine();
        }
    }
}


Array of String and Float

using System;

namespace Array_2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] names = new string[5];
            float[] scores = new float[5];
            names[0] = "Dara";
            scores[0] = 90;
            names[1] = "Kunthear";
            scores[1] = 95.5f;
            names[2] = "Veasna";
            scores[2] = 70;
            names[3] = "Sambo";
            scores[3] = 100;
            names[4] = "Bopha";
            scores[4] = 90;
            for (int i = 0; i < names.Length; i++)
            Console.WriteLine(names[i]+ "," + scores[i]);
            Console.ReadLine();
        }
    }
}

Array of String

using System;

namespace Array_1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] names = new string[5];
            names[0] = "Dara";
            names[1] = "Kunthear";
            names[2] = "Sambo";
            names[3] = "Veasna";
            names[4] = "Bopha";

            for (int a = 0; a < names.Length; a++)
            Console.WriteLine(names[a]);
            Console.ReadLine();

        }
    }
}

Thursday, April 7, 2016

White a loop to display number like this format?

3
6
12
15
18
21
24
27
30

Method 1:

 for(int i=3; i<31; i+=3)
Console.WriteLine(i);

Method 2:

 int i, j;
for(i=1; i <=10; a++)
{  j=3*i;
Console.WriteLine(j); }

Method 3:

int i=1;
while(i<11)
{ Console.WriteLine(i*3);
i +=1; }