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
View Answer
Explanation: None.
2. Which of these methods is a rounding function of Math class?
a) Max()
b) Min()
c) Abs()
d) Round()
View Answer
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
View Answer
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)
View Answer
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)
View Answer
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
View Answer
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
View Answer
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
View Answer
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
View Answer
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
View Answer
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
Sanfoundry Global Education & Learning Series – C# Programming Language.
To practice all areas of C# language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Check Computer Science Books
- Apply for C# Internship
- Check C# Books
- Practice Computer Science MCQs
- Check MCA Books