Users Online

· Guests Online: 95

· Members Online: 0

· Total Members: 188
· Newest Member: meenachowdary055

Forum Threads

Newest Threads
No Threads created
Hottest Threads
No Threads created

Latest Articles

C# Questions & Answers ? Rounding Functions

C# Questions & Answers – Rounding Functions

 

 

This section of our 1000+ C# MCQs focuses on rounding functions in C# Programming Language.

 

 

 

1. Which among the given classes provides types of rounding functions?
a) Math
b) Process
c) System
d) Object

Answer: a
Explanation: None.

 

 

 

2. Which of these methods is a rounding function of Math class?
a) Max()
b) Min()
c) Abs()
d) Round()

Answer: d
Explanation: Round() rounds up a variable to nearest integer.

 

 

 

3. Which of these classes contains only floating point functions?
a) Math
b) Process
c) System
d) Object

Answer: a
Explanation: Math class contains all the floating point functions that are used for general purpose mathematics methods. Example : sin(), cos(), exp(), sqrt() etc.
 

 

 

4. Which of these method returns a smallest whole number greater than or equal to variable X?
a) double Ciel(double X)
b) double Floor(double X)
c) double Max(double X)
d) double Min(double X)

Answer: a
Explanation: Ciel(double X) returns the smallest whole number greater than or equal to variable X.

 

 

 

5. Which of these methods return a largest whole number less than or equal to variable X?
a) double Ciel(double X)
b) double Floor(double X)
c) double Max(double X)
d) double Min(double X)

Answer: b
Explanation: double Floor(double X) returns a largest whole number less than or equal to variable X.
 

 

 

 

6. Which of the following functions return absolute value of a variable?
a) Abs()
b) Absolute()
c) absolutevariable()
d) None of the mentioned

Answer: a
Explanation: Abs() returns the absolute value of a variable.

 

 

 

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

  1.  public class A
  2.  {
  3.      public int x;
  4.      public int y;
  5.      public void display() 
  6.      {
  7.          Console.WriteLine(x + " " + y);
  8.      }
  9.  }
  10.  class Program
  11.  {
  12.      static void Main(string[] args)
  13.      {
  14.          A obj1 = new A();
  15.          A obj2 = new A();
  16.          obj1.x = 1;
  17.          obj1.y = 2;
  18.          obj2 = obj1;
  19.          obj1.display();
  20.          obj2.display();
  21.      }
  22.  }

a) 1 2 0 0
b) 1 2 1 2
c) 0 0 0 0
d) Run time exception

Answer: b
Explanation: None.
Output:

 

 1 2 1 2

 

 

 

 

 

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

  1. class Program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.         double x = 3.14;  
  6.         int y = (int) Math.Abs(x);
  7.         Console.WriteLine(y);
  8.     }
  9. }

a) 0
b) 3
c) 3.0
d) 3.1

Answer: b
Explanation: None.
Output:

 

  3

 

 

 

 

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

  1. class Program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.         double x = 3.14;  
  6.         int y = (int) Math.Ceiling(x);
  7.         Console.WriteLine(y);
  8.     }
  9. }

a) 0
b) 3
c) 3.0
d) 4

Answer: d
Explanation: Ceiling(double x) returns the smallest whole number greater than or equal to variable x.
Output:

 

 4

 

 

 

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

  1. class Program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.         double x = 3.14;  
  6.         int y = (int) Math.Floor(x);
  7.         Console.WriteLine(y);
  8.     }
  9. }

a) 0
b) 3
c) 3.0
d) 4

Answer: b
Explanation: double Floor(double X) returns the largest whole number less than or equal to variable X. Here, the smallest whole number less than 3.14 is 3.
Output:

 

 3

 

Comments

No Comments have been Posted.

Post Comment

Please Login to Post a Comment.

Ratings

Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Render time: 0.78 seconds
10,837,897 unique visits