Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int rectangle(double w, double h, double *P, double *S){
- if(w <= 0 || h <= 0){
- return -1;
- }
- *P = 2 * (w + h);
- *S = w * h;
- return 0;
- }
- int main(){
- double a, b, P, S;
- while(scanf("%lf %lf", &a, &b) != EOF){
- if(rectangle(a, b, &P, &S) == -1){
- fprintf(stderr, "Invalid rectangle sides!\n");
- }else{
- printf("S = %.2lf", S);
- printf("P = %.2lf", P);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment