//p01.c --- using variable 使用變數 //@CopyLeft by tsaiwn@csie.nctu.edu.tw // #include #include double x; // (注意 1) 變數 variable; // C++ 式的註解 comment int main( ) { // 大多數 main program 都這樣開頭 printf("Give me x: "); scanf("%lf", &x); printf(" sqrt 根號 %f =%f\n ", x, sqrt(x) ); printf("Bye bye!\n"); return 0; // 告知作業系統(OS)表示我們這主程式正常結束 } // main( /****** Running Script D:\test> path C:\TC\BIN;%path% D:\test> path C:\Dev-Cpp\bin;%path% D:\test> gcc p01.c Give me x: 5 sqrt 根號 5.000000 =2.236068 Bye bye! D:\test> a Give me x: 3 sqrt 根號 3.000000 =1.732051 Bye bye! D:\test> a Give me x: 9 sqrt 根號 9.000000 =3.000000 Bye bye! D:\test> D:\test> a.exe Give me x: 2 sqrt 根號 2.000000 =1.414214 Bye bye! D:\test> tcc p01.c Turbo C++ Version 3.00 Copyright (c) 1992 Borland International p01.c: Turbo Link Version 5.0 Copyright (c) 1992 Borland International Available memory 4106928 D:\test> p01.exe Give me x: 2 sqrt 根號 2.000000 =1.414214 Bye bye! D:\test> p01 Give me x: 9 sqrt 根號 9.000000 =3.000000 Bye bye! D:\test> **************************************/