Files
CSTutorials/Numbers.cs

44 lines
1022 B
C#

//C#/Tutorials/Numbers.cs
//Matthew Ellison
// Created: 07-29-20
//Modified: 07-29-20
//This is a simple hello world program
using System;
namespace mee{
public class Numbers{
public static void Main(string[] args){
int i1 = 1;
int i2 = 2;
int i3 = 3;
int div = i3/i2;
Console.WriteLine($"3/2i = {div}\n");
float f1 = 1.0F;
float f3 = 3.0F;
float fDiv = f1/f3;
double a = 1.0;
double b = 3.0;
double c = a / b;
//Decimal has a smaller range, but a greater precision than double
decimal d = 1.0M;
decimal e = 3.0M;
decimal f = d / e;
Console.WriteLine($"Float: {Single.MinValue} - {Single.MaxValue}");
Console.WriteLine($"Double: {Double.MinValue} - {Double.MaxValue}");
Console.WriteLine($"Decimal: {Decimal.MinValue} - {Decimal.MaxValue}");
Console.WriteLine($"1/3F = {fDiv}");
Console.WriteLine($"1/3D = {c}");
Console.WriteLine($"1/3M = {f}\n");
double answer = Math.Pow(2.50, 2) * Math.PI;
Console.WriteLine($"area = {answer}");
}
}
}