/*練習—02|2. 輸入一個圓半徑(r)當r>=0時,計算並輸出圓的面積和周長,否則,輸出提示信息。*/


 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 int main()  4 {  5 
 6     int t;  7     double r, s ,c;  8 
 9     do{ 10         printf ("請輸入一個圓的半徑值r: "); 11         scanf ("%lf", &r); 12         if (r >= 0) 13  { 14             s = 3.14 * r * r; 15             c = 2 * 3.14 * r; 16             printf("圓的面積s = %.2lf\n",s); 17             printf("圓的周長c = %.2lf\n",c); 18  } 19         else
20             printf("您輸入的半徑確定大於等於0嗎?\n"); 21         printf("您需要再輸入一次r值嗎?\n"); 22         printf("Yes --- 按數字鍵【1】\n"); 23         printf("No --- 按數字鍵【0】\n"); 24         scanf ("%d",&t); 25 
26       } while ( t == 1 ); 27 
28     return 0; 29 }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM