Thursday, 28 November 2013

C# IMPLEMENTATION OF GOTO AND LABEL -----------|||||||||||||||||||||\\\\\\\\

CODE;

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

namespace GotoNLabelProgram
{
    public class Program
    {
        public static void Main(string[] args)
        {
            for (int i = 1; i < 100; i++)
            {
                Console.WriteLine(" ");
                if (i>= 10)
                    break;
                for (int j = 1; j < 100; j++)
                {
              //      Console.WriteLine(" ");
                //    if (j == i)
                 //   {
                        Console.Write(" * ");
                        if (j == i)
                            goto loop1;

                    }
                loop1: continue;
                }
                Console.WriteLine("Termination by Break");
                Console.ReadKey();
              
            }
      
        }
    }

OUTPUT:


C# BREAK N CONTINUE IMPLEMENTATION---------|||||||||||||||||||

CODE:

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

namespace ContinueAndBreakProgram
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 10;
            while (n < 200)
            {
                if (n < 50)
                {
                    Console.WriteLine(" " + n);
                    n = n + 10;
                    continue;
                }
                if (n == 50)
                {
                    Console.WriteLine();
                    n = n + 10;
                    continue;
                }
                if (n > 90) break;
                   
                Console.WriteLine(" " + n);
                n = n + 10;
            }
            Console.WriteLine();
            Console.ReadKey();
        }
    }
}

OUTPUT:


C# Implementation of For N Foreach in the same program-----|||||||||

CODE:

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

namespace CSharpForNForeach
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a;
            a = new int[7];
            for (int i = 0; i < 7; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }
            Console.WriteLine("\n");
            Console.WriteLine("-------Numbers that You have entered are--------:");
            Console.WriteLine("\n");
            foreach (int m in a)
            {
                Console.WriteLine(" " + m);

            }
            Console.WriteLine();
            Console.ReadKey();
        }
    }
}

OUTPUT:

Wednesday, 27 November 2013

C# Matrx Multiplication Program using Multidimensional Array-----------||||||||||||

Code:

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

namespace ArrayMatrixMultiplication
{

    class Program
    {
        static int ROWS=3;
        static int COLUMNS=3;
     
       

     

       
       
        static void Main(string[] args)
        {
            int [,] a=new int[ROWS,COLUMNS];
            Console.WriteLine("\n Enter Your First Matrix");
            for (int i = 0; i < ROWS; i++)
            {
                for (int j = 0; j < COLUMNS; j++)
                {
                    a[i, j] = int.Parse(Console.ReadLine());
                }
            }
                int [,] b=new int[ROWS,COLUMNS];
                Console.WriteLine("Enter Your Second Matrix");
                for (int i = 0; i < ROWS; i++)
                {
                    for (int j = 0; j < COLUMNS; j++)
                    {
                        b[i, j] = int.Parse(Console.ReadLine());
                    }
                }
                int[,] c = new int[ROWS, COLUMNS];
                Console.WriteLine("Matrix Multiplication Is");
                Console.WriteLine("\n");
              
                for (int i = 0; i < ROWS; i++)
                {
                    for (int j = 0; j < COLUMNS; j++)
                    {
                        for (int k = 0; k < 3; k++)
                        {
                            c[i, j] = 0;
           
                            c[i, j]  = a[i, k] * b[k, j];
                           
                            Console.Write(c[i,j]+" ");
                           
                        }
                        Console.WriteLine("  ");
                    }
                    Console.ReadKey();
                }
              

        }
    }
}


Output: