A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C# program for type conversion from double to int
Q:

C# program for type conversion from double to int

0

Syntax:

    int_variable = (int)double_variable;

Example:

    Input:
    double a = 123456.789;
    int b = 0;

    //type conversion
    b = (int)a;

    Output:
    a: 123456.789
    b: 123456

 

All Answers

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

C# code for type conversion from double to int

// C# program for type conversion from double to int 
using System;
using System.IO;
using System.Text;

namespace IncludeHelp
{
    class Test
    {
        // Main Method 
        static void Main(string[] args)
        {
            double a = 123456.789;
            int b = 0;

            //type conversion
            b = (int)a;

            Console.WriteLine("value of a: {0}", a);
            Console.WriteLine("value of b: {0}", b);

            //hit ENTER to exit the program
            Console.ReadLine();
        }
    }
}

Output

value of a: 123456.789
value of b: 123456

 

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

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now