Programming Exercise of C# Operator

In this chapter you will learn:

  • How to solve programming problems using C# operators?
  • How to use different type of operator in a program?
  • How to select best operator to solve programming exercises?
Qu1: Write a program to calculate (a+b)2.
Hint: (a*a + b*b + 2*a*b)
Qu2: Write a program to calculate formulae πr2.
Qu3: Write a program to check whether input number is even or odd.
Qu4: Write a program to calculate power of given number by user.
Qu5: Write a program to calculate area of triangle. Take required input from user and then calculate the area of triangle.


In this chapter, you did programming exercises of C# operators. In next session you will learn about different types of C# conditional constructs.

8 thoughts on “Programming Exercise of C# Operator”

    1. Dim a, b, x, y, z As Integer
      Console.WriteLine(“enter a=”)

      a = Console.ReadLine()
      Console.WriteLine(“enter b=”)

      b = Console.ReadLine()
      x = a ^ 2 + b ^ 2
      y = 2 * a * b
      z = x + y
      Console.WriteLine(“z=” & z, z)

  1. Please find the code below:

    int a = Int32.Parse(Console.ReadLine());
    Console.Write(“Enter value of b :\t\t”);
    int b = Int32.Parse(Console.ReadLine());
    int result = (a * a + b * b + 2 * a * b);
    Console.WriteLine(” (a+b)^2 = {0}”,result);

Leave a Reply

Your email address will not be published. Required fields are marked *