# C# program to calculate the Cosine(X) using a predefined method

Here, we are going to learn about the Cosine(X), and learn how to calculate the Cosine(X) using a predefined method in C#?
Submitted by Nidhi, on September 22, 2020

Here, we calculate the Cosine(X) using Cos() method of Math class.

Program:

The source code to calculate the Cosine(X) using the predefined method is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.

```//C# program to calculate the Cos(X)
//using the predefined method.

using System;

class Demo
{

static void Main(string[] args)
{
double val = 0.0F;

while(val<=5)
{
Console.WriteLine("Cos({0}) => {1}", val, Math.Cos(val));
val++;
}
Console.WriteLine();
}
}
```

Output:

```Cos(0) => 1
Cos(1) => 0.54030230586814
Cos(2) => -0.416146836547142
Cos(3) => -0.989992496600445
Cos(4) => -0.653643620863612
Cos(5) => 0.283662185463226

Press any key to continue . . .
```

Explanation:

Here, we created a class Demo that contains the Main() method, the Main() is the entry point of the program, here we calculated the Cosine(X) using the predefined method Cos() of Math class. Here we calculated Cosine(X) for values 0 to 5 and print the results on the console screen.

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates