#include<stdio.h> int main(void) { int i,n; double x,y; double fee(double x); printf("Enter n:"); scanf("%d",&n); for(i=1;i<=n;i++) { printf("Enter x:"); scanf("%Lf",&x); if(x<=0) printf("sorry you enter is wrony "); else{ y=fee(x); } printf("y=%.3f ",y); } return 0; } double fee(double x) { double y; if(x<=50) { y=0.53*x; } else { y=26.5+0.58*(x-50); } return y; }
#include<stdio.h> int main() { int i,n; double r,v,h; double cylinder(double r,double h); printf("enter n:"); scanf("%d",&n); for(i=1;i<=n;i++){ printf("Enter r and h: "); scanf("%lf%lf",&r,&h); if((r<=0)||(h<=0)) { printf("sorry you enter is wrony! "); } else{ v=cylinder(r,h); printf("V=%.3f ",v); } } return 0; } double cylinder(double r,double h) { double result; result=3.1415926*r*r*h; return result; }
#include<stdio.h> int main() { int n,i; double x,y; printf("Enter n:"); scanf("%d",&n); for(i=1;i<=n;i++){ printf("Enter x:"); scanf("%lf",&x); if(x<=0) printf("sorry you enter is wrony "); else if(x<=50){ y=0.53*x; } else{ y=26.5+0.58*(x-50); } printf("y=%.3f ",y); } return 0; }