C# 0 The Complete Reference



Download 4,07 Mb.
Pdf ko'rish
bet77/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   73   74   75   76   77   78   79   80   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

ivar

 (an 


int

 variable) is divided by 3, a whole-number division is 

performed, and the outcome is 33—the fractional component is lost. However, when 

dvar

(a

double

 variable) is divided by 3, the fractional component is preserved.

As the program shows, when you want to specify a floating-point value in a program, 

you must include a decimal point. If you don’t, it will be interpreted as an integer. For 

example, in C#, the value 100 is an integer, but the value 100.0 is a floating-point value.

There is one other new thing to notice in the program. To print a blank line, simply call 

WriteLine( )

 without any arguments.

The floating-point data types are often used when working with real-world quantities 

where fractional components are commonly needed. For example, this program computes 

the area of a circle. It uses the value 3.1416 for pi.

// Compute the area of a circle.

using System;

class Circle {

  static void Main() {

    double radius;

    double area;

    radius = 10.0;

    area = radius * radius * 3.1416;

    Console.WriteLine("Area is " + area);

  }

}

The output from the program is shown here:



Area is 314.16

Clearly, the computation of a circle’s area could not be satisfactorily achieved without the 

use of floating-point data.


Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   73   74   75   76   77   78   79   80   ...   1096




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish