Bu İki Kod Arasındaki Farkı Bana Söliyebilirmisiniz Acil !!
using System; namespace Operatorler { class DortIslem { static void Main(string[] args) { int x = 10; int y = 5; Console.WriteLine("x + y = {0}", x + y); Console.WriteLine("x - y = {0}", x - y); Console.WriteLine("x * y = {0}", x * y); Console.WriteLine("x / y = {0}", x / y); Console.ReadKey(); } } }
using System; namespace Operatorler { class DortIslem { static void Main(string[] args) { int x = 10; int y = 4; int intSonuc = x / y; float floatSonuc = x / y; double doubleSonuc = x / y; Console.WriteLine("x / y = {0}", intSonuc); Console.WriteLine("x / y = {0}", floatSonuc); Console.WriteLine("x / y = {0}", doubleSonuc); Console.ReadKey(); } } }
< Bu mesaj bu kişi tarafından değiştirildi ManyaKuu -- 21 Aralık 2012; 10:49:21 >
Fark yok müdür 1.kod 4 işlem yapıyo 2.kod sadece bölme.
Edit aradığın şey bu sanırım,böyle olursa intte sonuc 2 cıkar doubleda 2,5 float'tada 2,5 cıkar:
int x = 10; int y = 4; int intSonuc = x / y; float floatSonuc = (float)x / (float)y; double doubleSonuc = (double)x / (double)y; Console.WriteLine("x / y = {0}", intSonuc); Console.WriteLine("x / y = {0}", floatSonuc); Console.WriteLine("x / y = {0}", doubleSonuc); Console.ReadKey();
using System;
namespace Operatorler
{
class DortIslem
{
static void Main(string[] args)
{
int x = 10;
int y = 5;
Console.WriteLine("x + y = {0}", x + y);
Console.WriteLine("x - y = {0}", x - y);
Console.WriteLine("x * y = {0}", x * y);
Console.WriteLine("x / y = {0}", x / y);
Console.ReadKey();
}
}
}
******************************************************************************************************************
using System;
namespace Operatorler
{
class DortIslem
{
static void Main(string[] args)
{
int x = 10;
int y = 4;
int intSonuc = x / y;
float floatSonuc = x / y;
double doubleSonuc = x / y;
Console.WriteLine("x / y = {0}", intSonuc);
Console.WriteLine("x / y = {0}", floatSonuc);
Console.WriteLine("x / y = {0}", doubleSonuc);
Console.ReadKey();
}
}
}
< Bu mesaj bu kişi tarafından değiştirildi ManyaKuu -- 21 Aralık 2012; 10:49:21 >