double sqrt(double x);
Parameter:
x: giá trị không âm
Remark:
Hàm sqrt( ) sẽ trả về căn bậc 2 của x. Nếu x < 0, hàm sẽ trả về giá trị không xác định NaN.
Ví dụ:
#include <math.h> #include <stdio.h> #include <conio.h> int main( void ) { double question = 45.35, answer; answer = sqrt( question ); if( question < 0 ) printf( "Error: sqrt returns %f\n", answer ); else printf( "The square root of %.2f is %.2f\n", question, answer ); getch(); }
Kết quả:
Leave a Reply
You must be logged in to post a comment.