cos()
The cos()
returns the cosine of an argument given in radians.
Syntax
std::cos(n)
Example
Use cos()
to return the cosine of 3.1416
radians:
#include <iostream>#include <cmath>int main() {double x = 3.1416;double result;result = std::cos(x);std::cout << "The cosine of " << x << " radians is " << result << "\n";}
This results in the following output:
The cosine of 3.1416 radians is -1
Codebyte Example
Use cos()
to return the cosine of 25
degrees:
All contributors
- GaVi-_3 total contributions
- Christine_Yang271 total contributions
- garanews222 total contributions
- christian.dinh2476 total contributions
- Anonymous contributorAnonymous contributor3071 total contributions
- StevenSwiniarski474 total contributions
- GaVi-_
- Christine_Yang
- garanews
- christian.dinh
- Anonymous contributor
- StevenSwiniarski
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.