Home >>VB.Net Programs >VB.Net program to find the cosine value for the specified angle

VB.Net program to find the cosine value for the specified angle

Write a VB.Net Program to find the cosine value for the specified angle

Here, for the defined angle, we'll find the cosine value and print the result on the console screen.

Program :

The source code to find the cosine value is given below for the angle specified. The program given is compiled and successfully executed.

Example


Module Module1

    Sub Main()
        Dim cosine As Double = 0

        cosine = Math.Cos(2)
        Console.WriteLine("Cosine is: {0}", cosine)

        cosine = Math.Cos(0.3584)
        Console.WriteLine("Cosine is: {0}", cosine)

        cosine = Math.Cos(0.0)
        Console.WriteLine("Cosine is: {0}", cosine)
    End Sub
    
End Module
	
Output:
Cosine is: -0.416146836547142
Cosine is: 0.93645926426301
Cosine is: 1

Explanation:

We created a Module1 module in the program above that contains the Main() method. We created a cosine variable initialized with 0 in the Main() method.

cosine = Math.Cos(2)
Console.WriteLine("Cosine is: {0}", cosine)

cosine = Math.Cos(0.3584)
Console.WriteLine("Cosine is: {0}", cosine)

cosine = Math.Cos(0.0)
Console.WriteLine("Cosine is: {0}", cosine)

We find the cosine value for the defined angle values in the above code and then print them on to the console screen.


No Sidebar ads