My Report

C# Operators Test – 1


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. What will be the output of the following C# code?

    int i, j = 1, k;
    for (i = 0; i < 3; i++)
    {
        k = j++ - ++j;
        Console.Write(k + " ");
    }
  

2. What will be the output of the following C# code?

  static void Main(string[] args)
  {
      int a, b, c, x;
      a = 90;
      b = 15;
      c = 3;
      x = a - b / 3 + c * 2 - 1;
      Console.WriteLine(x);
      Console.ReadLine();
  }
 

3. What will be the output of the following C# code?

  static void Main(string[] args)
  {
      int a , b;
      int c = 10;
      int d = 12;
      int e = 5;
      int f = 6;
      a = c * (d + e) / f + d;
      Console.WriteLine(a);
      b = c * ( d + e / f + d);
      Console.WriteLine(b);
      if (a < b)
      {
          Console.WriteLine(" parentheses changes values");
      }
      else if (a > b)
      {
          Counterintelligence("they have same value");
      }
      Console.ReadLine();
  }
 

4. What will be the output of the following C# code?

 static void Main(string[] args)
 {
     float a = 16.4f;
     int b = 12;
     float c;
     c =  a * ( b + a) / (a - b) ;
     Console.WriteLine("result is :" +c);
     Console.ReadLine();
 } 

5. What will be the output of the following C# code?

  static void Main(string[] args)
  {
      int a, b, c, x;
      a = 80;
      b = 15;
      c = 2;
      x = a - b / (3 * c) * ( a + c);
      Console.WriteLine(x);
      Console.ReadLine();
  }    
 

6. What will be the output of the following C# code?

 static void Main(string[] args)
 {
     int n = 5;
     int x = 4;
     int z, c, k;
     z = 3 * x * x + 2 * x + 4 / x + 8;
     for (c = 1; c <= n; c++)
     {
         for (k = 1; k <= c; k++)
         {
             Console.Write(Convert.ToString(Convert.ToChar(z)));
             z++;
         }
         Console.WriteLine("\n");
     }
     Console.ReadLine();
 }

7. The correct way of incrementing the operators are:

8. What will be the output of the following C# code?

  static void Main(string[] args)
  {
      int b= 11;
      int c = 7;
      int r = 5;
      int e = 2;
      int l;
      int v = 109;
      int k;
      int z,t,p;
      z = b * c;
      t = b * b;
      p = b * r * 2;
      l = (b * c) + (r * e) + 10;
      k = v - 8;
      Console.WriteLine(Convert.ToString(Convert.ToChar(z)) + Convert.ToString(Convert.ToChar(t)) + " " + Convert.ToString(Convert.ToChar(p)) +   Convert.ToString(Convert.ToChar(l)) + Convert.ToString(Convert.ToChar(v)) + Convert.ToString(Convert.ToChar(k)));                
      Console.ReadLine();
  }
    

9. Correct order of priorities are:

10. What will be the output of the following C# code?

 static void Main(string[] args)
 {
     int n = 5;
     int x = 4;
     int z, c, k;
     for (c = 1; c <= n; c++)
     {
         for (k = 1; k <= c; k++)
     {
         z = 3 * x * x + 2 * x + 4 / x + 8;
         Console.Write(Convert.ToString(Convert.ToChar(z)));
     }
         Console.WriteLine("\n");
     }
     Console.ReadLine();
 }
 

 

Start practicing “1000 MCQs on C#”, and once you are ready, you can take tests on all topics by attempting our “C# Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.