User:Richardhsu

Exercise 1.3  (define (sqrlarge x y z) (if (> x y)                              (if (> y z)                                  (sumsq x y)                                  (sumsq x z)) (if (> x z)                                 (sumsq x y)                                  (sumsq z y)) )) (define (sumsq a b) (+ (sq a) (sq b))) (define (sq a) (* a a))  (define (sqrlarge x y z) (cond ((or (and (> x y) (> y z)) (and (> y x) (> x z)))                           (sumsq x y)) ((or (and (> x z) (> z y)) (and (> z x) (> x y)))                           (sumsq x z)) (else (sumsq y z)))) (define (sumsq a b) (+ (sq a) (sq b))) (define (sq a) (* a a))

 1st Algorithm in C

if ( x> y)    {if ( y> z)         sumsq=x^2 +y^2; else sumsq=x^2 +z^2; }                        else{ if ( x> z)        sumsq=x^2 +y^2; else sumsq=z^2 +y^2;

}

Print "The sum of the squares of the two larger numbers:",sumsq



2nd Algorithm in C

if ((( x> y)&& ( y> z)) ||(( y> x) &&( x> z))) {        sumsq=x^2 +y^2; }                       else{ if ((( x> z)&& ( z> y)) ||(( z> x) &&( x>y))) sumsq=x^2 +z^2; else sumsq=z^2 +y^2;

}

Print "The sum of the squares of the two larger numbers:",sumsq