View Full Version : Calculating square root and squared number

CM Xtasy

March 7th, 2011, 02:59 AM

I am so confused as to how to calculate a square root and squared number. I'll use X for example

Write a function (the heading line and the complete body) that calculates values. The variable x is an input parameter, data type double. Return the calculated value to the caller.

So the equation is X^2 + (Square root of 2)

I'm just stuck after:

#include <stdio.h>

#include <math.h>

int main ()

{

Can somebody help me?

Portmanteaufu

March 7th, 2011, 04:12 AM

I strongly suspect that the reason you haven't been helped on this already is that it sounds like a homework problem. Is that the case?

CM Xtasy

March 7th, 2011, 04:26 AM

Yes, it's for my major, and my professor isn't available. A forum is the only place of help for me at the moment.

ve4cib

March 7th, 2011, 04:30 AM

I suggest you read what functions are available in the C math library (http://www.cplusplus.com/reference/clibrary/cmath/).

You may just find a function that will give you the square root of a number and another one that raises one number to the power of another.

That should give you enough to get started on the problem.

Portmanteaufu

March 7th, 2011, 05:33 AM

Feel free to ask for help on smaller parts of your problem. (How to make a function, what a parameter is and how to pass one, etc.) At the moment you seem to be asking us to write the code for you, which is against the forum's policy.

ve4cib's advice was an excellent jumping-off point.

Powered by vBulletin® Version 4.2.2 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.