#include #include int main() /* This program can find square root of any number that >=0 and will stop when you enter a value that < 0 阿版權是蔡文能的, 歡迎拷貝分享初學者! */ { float onevar; /* 變數名稱隨便我取的啦 */ double ans; /* 用來放答案 */ printf("Find square root of X. Negative value will cease the program\n"); printf("X=? "); /* 還是問"X=?" 比較簡潔有力, 不用說onevar */ scanf("%f", &onevar); while(onevar >=0 ) { /*只要onevar大於或等於零我們就一直重複做{...} */ ans=sqrt(onevar); /*其實sqrt的參數也應該為double 型別*/ printf(" SQRT(%f)=%f\n", onevar, ans); printf("X=? "); scanf("%f", &onevar); } /* while(onevar */ return 0; }