Users Online
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Latest Articles
Articles Hierarchy
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
Explanation: None.
2. Which of these methods is a rounding function of Math class?
a) Max()
b) Min()
c) Abs()
d) Round()
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
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)
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)
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
Explanation: Abs() returns the absolute value of a variable.
7. What will be the output of the following C# code snippet?
-
public class A
-
{
-
public int x;
-
public int y;
-
public void display()
-
{
-
Console.WriteLine(x + " " + y);
-
}
-
}
-
class Program
-
{
-
static void Main(string[] args)
-
{
-
A obj1 = new A();
-
A obj2 = new A();
-
obj1.x = 1;
-
obj1.y = 2;
-
obj2 = obj1;
-
obj1.display();
-
obj2.display();
-
}
-
}
a) 1 2 0 0
b) 1 2 1 2
c) 0 0 0 0
d) Run time exception
Explanation: None.
Output:
1 2 1 2
8. What will be the output of the following C# code snippet?
-
class Program
-
{
-
static void Main(string[] args)
-
{
-
double x = 3.14;
-
int y = (int) Math.Abs(x);
-
Console.WriteLine(y);
-
}
-
}
a) 0
b) 3
c) 3.0
d) 3.1
Explanation: None.
Output:
3
9. What will be the output of the following C# code snippet?
-
class Program
-
{
-
static void Main(string[] args)
-
{
-
double x = 3.14;
-
int y = (int) Math.Ceiling(x);
-
Console.WriteLine(y);
-
}
-
}
a) 0
b) 3
c) 3.0
d) 4
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?
-
class Program
-
{
-
static void Main(string[] args)
-
{
-
double x = 3.14;
-
int y = (int) Math.Floor(x);
-
Console.WriteLine(y);
-
}
-
}
a) 0
b) 3
c) 3.0
d) 4
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