C# 0 The Complete Reference


PART II C h a p t e r   2 1



Download 4,07 Mb.
Pdf ko'rish
bet781/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   777   778   779   780   781   782   783   784   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART II

C h a p t e r   2 1 :  

E x p l o r i n g   t h e   S y s t e m   N a m e s p a c e    

621


public static double Sqr t(double 

v

)

Returns the square root of 



v.

public static double Tan(double 



v

)

Returns the tangent of 



v.

public static double Tanh(double 



v

)

Returns the hyperbolic tangent of 



v.

public static double Truncate(double 



v

)

Returns the whole number por tion of 



v.

public static decimal Truncate(decimal 



v

)

Returns the whole number por tion of 



v.

T

ABLE



 21-1 

Methods Defi ned by 

Math

(continued)

Method


Meaning

Here is an example that uses 



Sqrt( )

 to help implement the Pythagorean theorem. It 

computes the length of the hypotenuse given the lengths of the two opposing sides of a 

right triangle.

// Implement the Pythagorean Theorem.

using System;

class Pythagorean {

  static void Main() {

    double s1;

    double s2;

    double hypot;

    string str;

    Console.WriteLine("Enter length of first side: ");

    str = Console.ReadLine();

    s1 = Double.Parse(str);

    Console.WriteLine("Enter length of second side: ");

    str = Console.ReadLine();

    s2 = Double.Parse(str);

    hypot = Math.Sqrt(s1*s1 + s2*s2);

    Console.WriteLine("Hypotenuse is " + hypot);

  }

}

Here is a sample run:



Enter length of first side: 3

Enter length of second side: 4

Hypotenuse is 5

Next is an example that uses the 



Pow( )

 method to compute the initial investment 

required to achieve a desired future value given the annual rate of return and the number 

of years. The formula to compute the initial investment is shown here:



InitialInvestment

 = 


FutureValue

 / (1 + 


InterestRate

)

Years



www.freepdf-books.com


622

 

P a r t   I I :  



E x p l o r i n g   t h e   C #   L i b r a r y

Because



Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   777   778   779   780   781   782   783   784   ...   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