C 語言標準函數庫分類導覽 - math.h sin()

math.h 的函數 sin() 回傳參數的正弦值,單位為弧度。預設回傳值及參數的資料型態為 double ,另有 float 型態的 sinf() , long double 型態的 sinl() 。



sin() 的函數原型如下
double sin(double);
float sinf(float);
long double sinl(long double);


以下程式示範函數 sin() 的使用
#include <stdio.h>
#include <math.h>

int main(void)
{
    double i = -1.0;
    
    while (i <= 1.0) {
        printf("%f\n", sin(i));
        i += 0.1;
    }
    
    return 0;
}

/* 《程式語言教學誌》的範例程式
    http://pydoing.blogspot.com/
    檔名:csin.c
    功能:示範 math.h 中函數 sin() 的使用
    作者:張凱慶
    時間:西元2010年6月 */


編譯後執行,結果如下



您可以繼續參考


沒有留言: