Finding numbering even ,odd, factorial,multiplication table,revers number.(Operators:Concept C#)

Operators:


Operator in C# is a special symbol that specifies which operations to perform on operands. For example, in mathematics the plus symbol (+) signifies the sum of the left and right numbers. In the same way, C# has many operators that have different meanings based on the data types of the operands. C# operators usually have one or two operands. Operators that have one operand are called Unary operators.

The following table list some of the operators available in C#.


Finding  numbering....Even numbers Odd numbers :


 Finding even number,....


namespace evennumber
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 10;
            for (i = 2; i <= 10;i++ )
            {
                Console.WriteLine(i);
                i = i + 1;
         
            }
            Console.ReadKey();

        }
    }
}



 Finding odd, number.....

namespace oddnumber
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 10;
            for (i = 1; i <= 10;i++ )
            {
                Console.WriteLine(i);
                i = i + 1;
            }
            Console.ReadKey();

        }
    }
}







 Finding factorial number.


namespace factorial
{
    class Program
    {
        static void Main(string[] args)
        {
            int i, number, fact;
            Console.WriteLine("enter the number");
            number = int.Parse(Console.ReadLine());
            fact = number;
            for (i = number-1; i >= 1; i--)
            {
                fact = fact * i;
            }
            Console.WriteLine("factorial of agiven number is" + fact);
            Console.ReadKey();

        }
    }
}




 Finding  multiplication table,

namespace multiplication table
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("enter a number");
            int n = int.Parse(Console.ReadLine());
            int i = 1;
            while (i <= 10)
            {
                Console.WriteLine("{0}*{1} = {2}", n, i, n * i);
                i = i + 1;
                Console.ReadKey();

            }
        }
    }
}





 Finding revers number,..
namespace revers number
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("enter a number");
            int n = int.Parse(Console.ReadLine());
            individual(n);
            Console.ReadKey();
        }
        static void individual(int  n)
        {
            int s = 0;
          int r;
            while(n>0)
            {
                r = n % 10;
                s = s * 10 + r;
                n = n / 10;
                Console.WriteLine(s);
            }
        }

        }
    }



Comments