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