Q:

C# program to demonstrate the use of Truncate() method of Math class

0

C# program to demonstrate the use of Truncate() method of Math class

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

The source code to demonstrate the use of Truncate() method of Math class is given below. The given program is compiled and executed successfully.

using System;

class Sample
{
    //Entry point of Program
    static public void Main()
    {
        decimal decNum = 123.4567m;
        double dblNum = 123.4567;

        Console.WriteLine("Demonstration of Truncate method: ");
        Console.WriteLine(Math.Truncate(decNum));
        Console.WriteLine(Math.Truncate(dblNum));
    
    }
}

Output:

Demonstration of Truncate method:
123
123
Press any key to continue . . .

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now