Tuesday 4 December 2012

Marks Greade Checking


Marks Greade Checking

           //Marks Greade Checking



            Console.WriteLine("Enter your marks");
            int a = Convert.ToInt32(Console.ReadLine());

            if (a >= 85)
            {
                Console.WriteLine("Congrats Your Grade is A");
            }

            else if (a >= 75 && a <= 84)
            {
                Console.WriteLine("Congrats Your Grade is B");
            }

            else if (a >= 65 && a <= 74)
            {
                Console.WriteLine("Congrats Your Grade is C");
            }

            else if (a >= 50 && a <= 64)
            {

                Console.WriteLine("Congrats Your Grade is D");
            }

            else
            {
                Console.WriteLine("You are Failed, Practice hard to get passed");
            }

            Console.ReadLine();

fabonicci series


fabonicci series


            // fabonicci series


            Console.WriteLine("Enter a number to print fabonicci series till.");
            int a = int.Parse(Console.ReadLine());
            Console.WriteLine("fabonicci series till " + a + " is");
            int b = 0;
            int c = 1;

            Console.WriteLine(b);
            Console.WriteLine(c);
            for (int d = b + c; d <= a; d = b + c)
            {
                Console.WriteLine(d);
                b = c;
                c = d;
            }

            Console.ReadLine();


factorial


factorial

            // factorial

            Console.WriteLine("Enter a number to get factorial");
            int a = int.Parse(Console.ReadLine());
            int i = 1;
            int j = a;
            for (; a != 0; a--)
            {
                i = i * a;

            }
            Console.WriteLine("factorial of " + j + " is " + i);
            Console.ReadLine();




factorial



            // factorial


            Console.WriteLine("Enter a number to get factorial");
            int a = int.Parse(Console.ReadLine());

            for (; a != 0; a--)
            {
                Console.WriteLine(a);
            }
            Console.ReadLine();

Even odd number


Even odd number

            //Even odd number


            Console.WriteLine("Enter a Number to check Even Odd");
            int a = Convert.ToInt32(Console.ReadLine());

            if (a % 2 == 0)
            {
                Console.WriteLine("You have entered a even number");
            }
            else
            {
                Console.WriteLine("You have entered a odd number");
            }
            Console.ReadLine();

Printing Table with do while loop


Printing Table with do while loop


            //Table do while loop

         

            string c;

            do
            {
                Console.WriteLine("Enter a number to print table");
                int a = int.Parse(Console.ReadLine());

                Console.WriteLine("table of " + a + " is");

                int i = a;
                do
                {

                    Console.WriteLine(i);
                    i = i + a;
                }

                while (i <= a * 10);

             
 
                Console.WriteLine("Do You want to continue Y/N");
                c = Console.ReadLine();

                if(c!="Y" && c!="N")
                {
                    Console.WriteLine("Enter the correct value Y/N only");
                    Console.WriteLine("Do You want to continue Y/N");
                    c = Console.ReadLine();  
                }
             
 
            }
            while (c == "Y");