Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

C++ : Reference : C Library : cmath (math.h) : cos Search: login: sign in using: cplusplus.

com Information Documentation Reference Articles Forum Reference C Library IOstream Library Strings library STL Containers STL Algorithms Miscellaneous C Library cassert (assert.h) cctype (ctype.h) cerrno (errno.h) cfloat (float.h) ciso646 (iso646.h) climits (limits.h) clocale (locale.h) cmath (math.h) csetjmp (setjmp.h) csignal (signal.h) cstdarg (stdarg.h) cstddef (stddef.h) cstdio (stdio.h) cstdlib (stdlib.h) remember me [register]

cos
function
<cmath> double cos ( double x ); float cos ( float x ); long double cos ( long double x );

Compute cosine Returns the cosine of an angle of x radians. In C++, this function is overloaded in <complex> and <valarray> (see complex cos and valarray cos).

Parameters
x Floating point value representing an angle expressed in radians.

Return Value
Cosine of x.

Portability
In C, only the double version of this function exists with this name.

Example
1 2 3 4 5 6 /* cos example */ #include <stdio.h> #include <math.h> #define PI 3.14159265

cstring (string.h) 7 int main () 8 { ctime (time.h) 9 double param, result; 10 param = 60.0; cmath (math.h) 11 result = cos (param*PI/180); functions: 12 printf ("The cosine of %lf degrees is %lf.\n", 13 param, result ); abs 14 return 0; acos } asin atan Output: atan2 ceil The cosine of 60.000000 degrees is 0.500000. cos cosh exp See also fabs sin Compute sine (function) floor tan Compute tangent (function) fmod frexp ldexp log log10 modf pow sin sinh sqrt tan tanh macro constants: HUGE_VAL

Home page | Privacy policy cplusplus.com, 2000-2011 - All rights reserved - v2.9b Spotted an error? contact us

You might also like