<repo_name>sakshis24/TaviscaCodejamTraining2017<file_sep>/Stack_Implementation/Stack_Operations.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Stack_Implementation
{
   public class Stack_Operations
    {
        private int[] stack;
        private int size;
        private int top_of_stack = -1;

        public bool push(int data_value)
        {
            if (top_of_stack == size - 1)
            {
                Console.WriteLine("stack is empty");
                return false;
            }
            else
            {
                stack[++top_of_stack] = data_value;
                Console.WriteLine("stack is {0}", stack[top_of_stack]);
                return true;
            }
        }

        public int pop()
        {
            if (top_of_stack == -1)
            {
                Console.WriteLine("stack is empty");
                return int.MaxValue;
            }
            else
            {
                int k = stack[top_of_stack--];
                return k;
            }
        }









        public Stack_Operations(int size_of_array)
        {
            stack = new int[size_of_array];
            size = size_of_array;
        }


    }
}











    <file_sep>/Stack_Implementation/Program.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Stack_Implementation
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("enter the size of array");
            int size_of_datastructure = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("enter the data element to be inserted");
            int data_item = Convert.ToInt32(Console.ReadLine());
            Stack_Operations stackobject = new Stack_Operations(size_of_datastructure);
            int choice;
            bool op = true;
            while (op)
            {
                Console.WriteLine("Enter your choice");
                Console.WriteLine("1) PUSH/n 2)POP/n 3) Exit");
                choice = Convert.ToInt32(Console.ReadLine());

                switch (choice)
                {
                    case 1:
                        stackobject.push(data_item);
                        break;
                    case 2:
                        stackobject.pop();
                        break;
                    case 3:
                        op = false;
                        break;
                    default:
                        Console.WriteLine("invalid choice");
                        break;

                }
            }






        }
    }
}
<file_sep>/Queue_Implementation/Program.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Queue_Implementation
{
   public class Queue
    {
       public static void Main(string[] args)
        {
            Console.WriteLine("enter the size of queue");
            int size_of_Queue = Convert.ToInt32(Console.ReadLine());
            Queue_Operations q = new Queue_Operations(size_of_Queue);
            while (true)
            {
            int choice;
            Console.WriteLine("enter your choice 1) ENQUEUE/n 2)DEQUEUE/n 3)DISPLAY/n 4)EXIT");
            choice = Convert.ToInt32(Console.ReadLine());
            
             switch(choice)
                {

                    case 1:
                        Console.WriteLine("enter the element to be inserted");
                        int number_to_be_inserted = Convert.ToInt32(Console.ReadLine());
                        q.Enqueue(number_to_be_inserted);
                        break;
                    case 2: q.Dequeue();
                        break;
                    case 3:q.Display();
                        break;
                    case 4:Environment.Exit(100);
                        break;
                    default: Console.WriteLine("entered invalid choice");
                        break;










                }










            }
        }
    }
}
<file_sep>/Queue_Implementation/Queue_Operations.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Queue_Implementation
{
   public class Queue_Operations
    {
        private int[] queue_array;
        private int front = -1;
        private int rear = -1;
        int size_of_queue;

     public void Enqueue(int data_item)
        {
            if(rear==size_of_queue-1)
            {
                Console.WriteLine("OVERFLOW");
            }
            else
            {
                if (front == -1)
                {
                    front = 0;
                    Console.WriteLine("element to be inserted");
                    data_item = Convert.ToInt32(Console.ReadLine());
                    queue_array[++rear] = data_item;
                    Console.WriteLine("element inserted is {0}",queue_array[rear]);
                }    
            }
        }
      
        public void Dequeue()
        {
            if(front==-1||front>rear)
            {
                Console.WriteLine("Underflow");
            }
            else
            {
                
                Console.WriteLine("queue present element after dequeue {0}", queue_array[front]);
                front++;


            }

        }
        public void Display()
        {
            if(front==-1)
            {
                Console.WriteLine("queue is empty");
            }
            else
            {
                for(int i=front;i<=rear;i++)
                {
                    Console.WriteLine(queue_array[i] + " ");

                }
            }



        }










        public Queue_Operations(int size )
        {
            queue_array = new int[size];
            size_of_queue = size;

        }


    }
}
<file_sep>/Queue_using_two_Stacks/Program.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Queue_using_two_Stacks
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the size of the queue");
            int size = Convert.ToInt32(Console.ReadLine());
            Queue_using_arrays q = new Queue_using_arrays(size);
            while (true)
            {
                Console.WriteLine("Enter 1)Enqueue\n2)Dequeue3)Display\n4)Exit");
                int choice = Convert.ToInt32(Console.ReadLine());
                switch (choice)
                {
                    case 1:
                        Console.WriteLine("Enter an element");
                        q.Enqueue(Convert.ToInt32(Console.ReadLine()));
                        break;
                    case 2:
                        q.Dequeue();
                        break;
                    case 3:
                        q.Display();
                        break;
                    case 4:
                        Environment.Exit(1);
                        break;
                }
            }
        }
    }
}













        
<file_sep>/Queue_using_two_Stacks/Stack.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Queue_using_two_Stacks
{
    class Stack
    {

        private int top_of_stack = -1;
        private int[] stack;


        public bool push(int data)
        {
            if (top_of_stack >= stack.Length)
            {
                return false;
            }
            else
            {
                stack[++top_of_stack] = data;
                Console.WriteLine(stack[top_of_stack]);
                return true;
            }

        }
        public int pop()
        {
            if (top_of_stack == -1)
            {
                return int.MaxValue;
            }
            else
            {
                int k = stack[top_of_stack--];
                return k;
            }
        }

        public void display()
        {
            if (top_of_stack != -1)
            {

                for (int i = 0; i < top_of_stack; i++)
                {
                    Console.WriteLine(stack[i]);
                }
            }
            else
            {
                Console.WriteLine("empty");
            }
        }
        public Stack(int SizeOfStack)
        {
            stack = new int[SizeOfStack];
        }
    }
}



















    
<file_sep>/Queue_using_two_Stacks/Queue.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Queue_using_two_Stacks
{

        public class Queue_using_arrays
        {

            private Stack stack_inside, stack_outside;
            private int size_of_queue;



            public bool Enqueue(int data)
            {
                if (stack_inside.push(data))
                {
                    return true;
                }
                else return false;
            }

            public void Dequeue()
            {
                int i = stack_inside.pop(), temp;
                while (i != int.MaxValue)
                {
                    stack_outside.push(i);
                    i = stack_inside.pop();
                }
                temp = stack_outside.pop();
                i = stack_outside.pop();
                while (i != int.MaxValue)
                {
                    stack_inside.push(i);
                    i = stack_outside.pop();
                }

            }

            public void Display()
            {
                stack_inside.display();
            }

            public Queue_using_arrays(int SizeOfQueue)
            {
                stack_inside = new Stack(SizeOfQueue);
                stack_outside = new Stack(SizeOfQueue);
                size_of_queue = SizeOfQueue;
            }
        }
    }






<file_sep>/tavisca.training.2017.check_substring/Program.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace tavisca.training._2017.check_substring
{
    class Program
    {
        static void Main(string[] args)
        {

            Program p = new Program();



            p.push();
        }


        void push()
        {

            int top = -1;
            Console.WriteLine("enter the string:");
            String s = Console.ReadLine();
            var character = s.ToCharArray();
            Console.WriteLine("Original string: {0}", s);
            Console.WriteLine("Character array:");
            for (int i = 0; i < character.Length; i++)
            {
                Console.WriteLine("{0} {1}", i, character[i]);



            }

            Console.WriteLine("enter the string to compare:");
            String s1 = Console.ReadLine();
            var character1 = s1.ToCharArray();
            Console.WriteLine("String to compare: {0}", s1);
            Console.WriteLine(":");
            for (int j = 0; j < character1.Length; j++)
                Console.WriteLine("{0} {1}", j, character1[j]);

            if (s.Contains(s1))
            {
                Console.WriteLine("s is substring of s1");
            }
            else
            {
                Console.WriteLine("s is not a substring");
            }


            Console.ReadLine();

        }








    }
}

<file_sep>/Factorial/Program.cs
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



namespace Zeros_in_Factorial
    {
       public class Factorial
        {
           public  static void Main(string[] args)
            {
                Console.WriteLine("enter number :");
                int n = int.Parse(Console.ReadLine());
                long factorial = 1; int number_of_zero = 0;

                for (int i = 1; i <= n; i++)
                {
                    factorial = factorial * i;
                }


                Console.WriteLine(factorial);

                while (factorial % 10 == 0)
                {
                number_of_zero++;
                    factorial /= 10;
                }
                Console.WriteLine(number_of_zero);
                Console.ReadLine();





            }

        }
    }





