实验二 用c语言编写简单程序

 

 

 

#include<stdio.h>

int main(void)

{

         int i,n;

         double r,h,v;

 

         printf("Enter n:");

         scanf("%d",&n);

 

         for(i=0;i<=n;i++){

                   printf("Enter r and h:\n");

                   scanf("%lf%lf",&r,&h);

                   if(r>0&&h>0){

                            v=3.14*r*r*h;

                            printf("%.2f",v);

                   }

                   else{

                            printf("Error");

                   }

         }

         return 0;

}

 

 

   

 

 

posted @ 2013-10-17 13:05  zhaoyang16  阅读(148)  评论(0编辑  收藏  举报