What will be the output of the following C# code? [code] static void Main(string[] args) { int i = 10; double d = 35.78;

Trang Esther

New member
What will be the output of the following C# code?
Code:
 static void Main(string[] args)
 {
     int i = 10;
     double d = 35.78;
     fun(i);
     fun(d);
     Console.ReadLine();
 }
 static void fun(double d)
 {
     Console.WriteLine(d);
 }
A.
35.78
10
B.
10
35.00
C.
10
35.78
D. None of the mentioned
 
Answer: c
Explanation: ‘int’ datatype is sub datatype of ‘double’. Hence, when first part of func() is executed it is integer part and hence when the second part is executed it is double.
Output:
Code:
       10
       35.78
 

Tìm kiếm

Back
Top