Saturday 16 April 2016

Design a Console Application for populating Array List with Marks of students & perform following operations:

Enter marks of 10 students in ArrayList
Sort ArrayList in descending order
Remove lowest marks
Find out that whether arraylist is having 75 marks of any student or not
Remove all the items from arraylist.

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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList a1 = new ArrayList();
            Console.WriteLine("Marks of 10 Students : ");
            a1.Add(89);
            a1.Add(74);
            a1.Add(67);
            a1.Add(79);
            a1.Add(52);
            a1.Add(86);
            a1.Add(75);
            a1.Add(25);
            a1.Add(56);
            a1.Add(48);
            Console.WriteLine();
         
            foreach (int i in a1)
            {
                Console.Write(i + " ");
            }


            Console.WriteLine();
            Console.WriteLine();
            a1.Sort();
            a1.Reverse();
            Console.WriteLine("Sorted List ");
            foreach (int i in a1)
            {
               
                Console.Write(i + " ");
            }



            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            a1.Remove(25);
        Console.WriteLine("List After Removing Lowest Marks : ");
            foreach (int i in a1)
            {

                Console.Write(i + " ");
            }



            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Student Having 75 Marks or Not");
            Console.WriteLine(a1.Contains(75));



            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("After Removing All Items");
            Console.WriteLine();
            a1.Clear();
            Console.WriteLine("Empty List ");


            Console.ReadKey();
     
        }
    }
}


No comments:

Post a Comment