• C

Really simple question !


I need a very simple program. I am just starting to learn C by myself and I have no book. If you know a good book, let me know.
I want to know how to do the following program :
(example of passing parameters to a function)

-Ask the user to input 4 real numbers at the command prompt
-send the numbers to a function to perform the follwoing
 value=(a+b squared) + (c+d)squared)

and return the value to the main program and print result.
I need a wroking program please. I want to cut and paste. Thanks
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I won't do questions for you (EE has strict rules about doing "homework" problems).

I can point out good books:
Illustrating C by Donald Alcock ISBN 0521468213 - this is a great book for beginners.

The C language by Ritchie and Kernighan - de facto C book...its great (tho it might be a bit outdated). its treatment of pointers and arrays is fabulous.
haielAuthor Commented:
Who said this is a homeworke assignment. I am 42 years my friend.If I have a book I am sure this can be found as exaple oe something.Anyway thanks.
Since you are just starting C programming, I didn't use anything too complicated like arrays.  Here's a program that does what you asked for.

#include <stdio.h>

double calc(double,double,double,double);

void main(void) {
        double a,b,c,d;         /** Input numbers **/
        double res;             /** Result of expression evaluation **/

        printf("Enter A: ");

        printf("Enter B: ");

        printf("Enter C: ");

        printf("Enter D: ");

        res = calc(a,b,c,d);
        printf("The result is: %f\n\n",res);


double calc(double w, double x, double y, double z) {
        return ((w+x)*(w+x) + (y+z)*(y+z));

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
haielAuthor Commented:
Thanks alot.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.