HW02 Python運算子表達式
1. Notebooklm 2. 3. 學習卡 及測驗 4. 寫1個程式需附加說明 Create a README For Github 1. 專案名稱 car-speed-calculator 2. C 語言程式碼 檔案名稱: main.c c #include <stdio.h> int main() { float distance, time, speed; // Input distance in meters printf("Enter distance in meters: "); scanf("%f", &distance); // Input time in seconds printf("Enter time in seconds: "); scanf("%f", &time); // Calculate speed if (time > 0) { speed = distance / time; printf("Speed of the car = %.2f m/s\n", speed); } else { printf("Time must be greater than zero.\n"); } return 0; } 程式說明 #include <stdio.h> :引入標準輸入與輸出函式庫。 float distance, time, speed; :宣告距離、時間和速度變數。 scanf() :讓使用者透過鍵盤輸入距離和時間。 speed = distance / time; :使用距離除以時間計算速度。 if (time > 0) :確保時間大於零,避免除以零。 printf() :顯示計算結果。 %.2f :將速度顯示至小數點後兩位。 計算公式: Speed = Distance Time Speed = Time Distance 3. GitHub README.md...