Float data type is a numeric datatype that will accept numbers. Its a 32 bit sized datatype. The difference from integer datatype is that, float accepts fractional values. The float values when assigned to a variable are generally followed by a "F" at the end of the value.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
float a = 3.4567F;
float b = 5.7679F;
float answer = (a * a) + (b * b) + (2 * a * b); //a squared + b squared + 2ab
Console.WriteLine("The
final value is : {0}", answer);
Console.ReadLine();
}
}
}
Output:
No comments:
Post a Comment