1. //program to input integer array from user and then display it using for loop

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int []marks={88,89,90,78,77};
            int i;
            for(i=0;i<5;i++)
            {
                Console.WriteLine(marks[i]);
            }
            Console.ReadLine();
        }
    }
}

2. //program to input integer array of size 5 using while loop and then display the integer array using while loop

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int []marks={88,78,89,90,77};
	        int i=0;
        
	        Console.WriteLine("displaying marks");
	        i=0;
	        while(i<5)
	        {
		        Console.WriteLine("marks in subject " + (i+1) + " are " + marks[i]);
		        i++;
	        }
       
            Console.ReadLine();
        }
    }
}

3. //program to input an integer array of size 5 from the user and calculate total of the integer array using for loop

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int []marks={88,89,90,78,77};
            int i;
            int total=0;
            for(i=0;i<5;i++)
	        {
		
		        total=total+marks[i];
	        }
	        Console.WriteLine("total of marks in five subjects is " + total);

       
            Console.ReadLine();
        }
    }
}

4. //program to input an integer array of marks in 5 subjects and calculate percentage

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int []marks={88,89,90,78,77};
            int i;
            double total=0;
            double percentage;
            for(i=0;i<5;i++)
	        {
		
		        total=total+marks[i];
	        }
            percentage=total/5;
	        Console.WriteLine("total of marks in five subjects is " + total);
            Console.WriteLine("percentage of student is " + percentage);
       
            Console.ReadLine();
        }
    }
}

5. //program to input array of 10 integer elements and find sum of even and odd numbers using for loop

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int []a={89,90,91,82,84,85,78,75,79,77};
	        int i;
	        int sumeven=0,sumodd=0;
        
	        for(i=0;i<10;i++)
	        {
		        if(a[i]%2==0)
		        {
			        sumeven=sumeven+a[i];
		        }
		        else
		        {
			        sumodd=sumodd+a[i];
		        }
	        }
	        Console.WriteLine("sum of even numbers is " + sumeven);
	        Console.WriteLine("sum of odd numbers is " + sumodd);
       
            Console.ReadLine();
        }
    }
}

6. //program to input an array of 10 integer elements and calculate largest even and odd number from the array

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int []a={1,20,190,4,7,8,9,10,11,13};
            int i;
            int leven=0,lodd=1;
    
    
            for(i=0;i<10;i++)
            {
                if(a[i]%2==0)
                {
                    if(a[i]>leven)
                    {
                        leven=a[i];
                    }
                }
                else
                {
                    if(a[i]>lodd)
                    {
                        lodd=a[i];
                    }
                }
            }
            Console.WriteLine("largest even number is " + leven);
            Console.WriteLine("largest odd number is " + lodd);
            Console.ReadLine();
        }
    }
}

7. //program to initialize an array of 10 elements and find smallest even and odd number

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int []a={1,20,190,4,7,8,9,10,11,13};
            int i;
            int smalleven=a[9];
            int smallodd=a[9];
            for(i=0;i<10;i++)
            {
                if(a[i]%2==0)
                {
                    if(a[i]<smalleven)
                    {
                        smalleven=a[i];
                    }
                }
                else
                {
                    if(a[i]<smallodd)
                    {
                        smallodd=a[i];
                    }
                }
            }
            Console.WriteLine("smallest even number is " + smalleven);
            Console.WriteLine("smallest odd number is " + smallodd);
            Console.ReadLine();
        }
    }
}

8. //program to find maximum and minimum number in an integer array

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int []a={3,2,12,34,56,78,90,99,97,56};
            int i;
            int high=a[0];
            int low=a[0];
            for(i=1;i<10;i++)
            {
                if(a[i]>high)
                {
                    high=a[i];
                }
                    if(a[i]<low)
                {
                    low=a[i];
                }

            }
            Console.WriteLine("highest element in the array is " + high);
            Console.WriteLine("lowest element in the array is " + low);
            Console.ReadLine();
        }
    }
}

9. //program to input a integer array from the user and find its length

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int []marks={88,89,90,78,77};

            Console.WriteLine("length of array is " + marks.Length);
            Console.ReadLine();
        }
    }
}

10. //program to input a double array from user and display it using for loop

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            double []arr={90.9,89.8,78.8,67.8,88.9};
	        int i;
        
	
	        for(i=0;i<5;i++)
	        {
		        Console.WriteLine("value at position " + i + " is "+ arr[i]);
	        }
            Console.ReadLine();
        }
    }
}

11. //program to input a string or a char array from the user and then display it

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            char []name={'a','b','c','d','e'};
            int i;
            for(i=0;i<5;i++)
            {
                Console.WriteLine(name[i]);
            }
            Console.ReadLine();
        }
    }
}

12. //program to input a char array (string) and count number of vowels in the string

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            char []str={'s','d','e','y','o'};
	        char ch;
	        int i;
	        int count=0;
                int l;
                l=str.Length;
	        for(i=0;i<l;i++)
	        {
		        ch=str[i];
		        if((ch=='a') || (ch=='e') || (ch=='i') || (ch=='o') || (ch=='u'))
		        {
			        count++;
		        }
	        }
	        Console.WriteLine("number of vowels in the string are " + count);
            Console.ReadLine();
        }
    }
}

13. //program to input an integer array and pass this array to method , method prints the integer array

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

namespace ConsoleApplication1
{
    class passarray
    {
        public void printarr(int[] arr)
        {
            int i;
            for(i=0;i<arr.Length;i++)
            {
                Console.WriteLine(arr[i]);
            }
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            int []marks={88,89,90,78,77};
            passarray ob=new passarray();
            ob.printarr(marks);
            Console.ReadLine();
        }
    }
}

