Write a C# program that reads two arrays and checks whether they are equal.

Write a C# program that reads two arrays and checks whether they are equal.

Write a C# program that reads two arrays and checks whether they are equal.

Object:

Write a C# program that reads two arrays from the console and checks whether they are equal. C# Projects with Source Code

Code:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace Lab_5a

{

    class chkequal

    {

        public void chk()

        {

            int i, j,a,b;

            Console.WriteLine(“How many value your enter in Arrays 1?”);

            a = Convert.ToInt32(Console.ReadLine());

            int[ ] arr1 = new int[a];

            Console.WriteLine(“\nPlease Enter Arrays 1 Values. \n”);

            for (i = 0; i < a; i++)

            {

                j = Convert.ToInt32(Console.ReadLine());

                arr1[i] = j;

            }

            Console.WriteLine(“\nHow many value your enter in Arrays 2?”);

            b = Convert.ToInt32(Console.ReadLine());

            int[] arr2 = new int[b];

            Console.WriteLine(“\nPlease Enter Arrays 2 Values. \n”);

            for (i = 0; i < b; i++)

            {

                j = Convert.ToInt32(Console.ReadLine());

                arr2[i] = j;

            }

            int a1 = arr1.Length;

            int a2 = arr2.Length;

            Console.WriteLine(“—————————————–“);

            if (a1 == a2)

            {

                Console.WriteLine(“\nArrays are Equal.”);

            }

            else

                Console.WriteLine(“\nArrays are not Equal.”);

        }

    }

    class Program

    {

        static void Main(string[] args)

        {

            chkequal i = new chkequal();

            i.chk();

            Console.ReadKey();

        }     

    }

}

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

namespace Lab_5a
{
    class chkequal
    {
        public void chk()
        {
            int i, j,a,b;
            Console.WriteLine("How many value your enter in Arrays 1?");
            a = Convert.ToInt32(Console.ReadLine());
            int[] arr1 = new int[a];
            Console.WriteLine("\nPlease Enter Arrays 1 Values. \n");
            for (i = 0; i < a; i++)
            {
                j = Convert.ToInt32(Console.ReadLine());
                arr1[i] = j;
            }
            Console.WriteLine("\nHow many value your enter in Arrays 2?");
            b = Convert.ToInt32(Console.ReadLine());
            int[] arr2 = new int[b];
            Console.WriteLine("\nPlease Enter Arrays 2 Values. \n");
            for (i = 0; i < b; i++)
            {
                j = Convert.ToInt32(Console.ReadLine());
                arr2[i] = j;
            }
            int a1 = arr1.Length;
            int a2 = arr2.Length;
            Console.WriteLine("-----------------------------------------");
            if (a1 == a2)
            {
                Console.WriteLine("\nArrays are Equal.");
            }
            else
                Console.WriteLine("\nArrays are not Equal.");
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            chkequal i = new chkequal();
            i.chk();
            Console.ReadKey();
        }
       
    }
}

Output:

Write a C# program that reads two arrays and checks whether they are equal.

Another C# Program: C# Program Calculating the Area of a Rectangle

Another C# Program: C# Program that Subtracts two user-defined numbers

Another C# Program: C# Program Create a class student with a data members name and calculate marks and percentage.

Another C# Program: C# program to count vowels in a string

Another Program: Write a C# program to create a static function factorial and calculate factorial of the number.

1 thought on “Write a C# program that reads two arrays and checks whether they are equal.”

  1. Pingback: C# Program Create an inheritance hierarchy that a bank might use to represent the customer's bank accounts.

Leave a Comment

Your email address will not be published. Required fields are marked *