# Making quadrat on c programming language

Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last
• 12-29-2012
loserone+_+
Making quadrat on c programming language
Does anybody know how to make a quadrat on a number or variabel? I searching it on anyweb but i didnt find the solution, please help! I wanna making a math calculation using c programming and by myself quadrat is vital thing i must know ......
• 12-29-2012
smokeyangel

Do you maybe mean a square root (Square Roots) or a square (x2)?

Code:

```#include <math.h> void test(void) {   double res = sqrt(x); }```
sqrt - C++ Reference

For x2 you may as well just do x*x. For xn

Code:

```#include <math.h> void test(void) {   double res = pow(x, n); }```
pow - C++ Reference

Sorry if I misunderstood your question. If you do actually mean this: Quadrat - Wikipedia, the free encyclopedia then no I don't have a clue how to represent it in C :D
• 12-29-2012
whiteflags
Quadrat - Wikipedia, the free encyclopedia ? You do kind of have to be careful to know what you want, or you risk communicating a different idea. What are you doing again?
• 12-29-2012
loserone+_+
yeah that is what i mean :D
in my country language, square root are called kuadrat, so i think kuadrat = quadrat = square root
what if x with square root 3 or more?
and must we using double res = pow(x, n);

Quote:

Originally Posted by smokeyangel

Do you maybe mean a square root (Square Roots) or a square (x2)?

Code:

```#include <math.h> void test(void) {   double res = sqrt(x); }```
sqrt - C++ Reference

For x2 you may as well just do x*x. For xn

Code:

```#include <math.h> void test(void) {   double res = pow(x, n); }```
pow - C++ Reference

Sorry if I misunderstood your question. If you do actually mean this: Quadrat - Wikipedia, the free encyclopedia then no I don't have a clue how to represent it in C :D

• 12-29-2012
loserone+_+
sorry, i didnt know the correct english for square root,

Quote:

Originally Posted by whiteflags
Quadrat - Wikipedia, the free encyclopedia ? You do kind of have to be careful to know what you want, or you risk communicating a different idea. What are you doing again?

• 12-29-2012
Crossfire
ok so you want the square root and thats it, or do you want other roots, like cube root (cubed root of 27 = 3 meaning 3*3*3)
• 12-29-2012
whiteflags
Quote:

what if x with square root 3 or more?
A cube root or nth root can be expressed mathematically as raising to a fractional power n^(1/3) or n^(1/6) for example. So use pow.
• 12-29-2012
loserone+_+
yeahhh, thats it.
not only cube root, more of it i will use that
like 64 = 2 meaning 2*2*2*2*2*2
• 12-29-2012
loserone+_+
Quote:

Originally Posted by whiteflags
So use pow.

i see that! :) by the way what is that "pow" acronym?
and how i use it with a simple code?
when i see "double res" thing, it makes me confused,
must it exist before pow or doesnt must?
• 12-29-2012
Crossfire
yeah go with what WhiteFlags said

Code:

`double res = pow(x, (1/n));`
is the same as
Code:

```double res; res = pow(x, (1/n));```
where x is your whole number, and the n is the # of roots

ie x=27 n=3 res would =3, or x=64 n=6 res would be n=6 res would be 2.
• 12-29-2012
loserone+_+
Quote:

Originally Posted by Crossfire
yeah go with what WhiteFlags said

Code:

`double res = pow(x, (1/n));`
is the same as
Code:

```double res; res = pow(x, (1/n));```
where x is your whole number, and the n is the # of roots

ie x=27 n=3 res would =3, or x=64 n=6 res would be n=6 res would be 2.

hemm,
is that "x" thing, are declared variables by using int, float?
and "n" thing are constant?
res = result, right?
if i wanna print to the screen, would it be like this,
printf("The Result %d", res);
• 12-29-2012
Crossfire
you can have the "user" give both X and N, so they could choose regular square root of 9(x=9 n=2), or cubed root of 27 (x=27 n=3) quad root of 1296 (x=1296 n=4) ect

yes x, n, res all variables
x = big number
n = #of roots
res = result

and make sure to have all doubles, so you get the decimals if not a true root, either that or use type casting to divide and get the decimals
• 12-29-2012
whiteflags
The best thing is to use doubles for all the numbers. It causes the least trouble. Values like 1.0 / 3.0 require the places after the decimal point too.

The only thing you don't seem to know is that pow is a function from math.h. Might want to review your C book!
• 12-29-2012
loserone+_+
yeah i know, pow function is a function from math.h
by the way, i know to use sqrt using header math.h
but i didnt know how to make square root.
doubles are both of int and float right? cool :cool:
• 12-29-2012
whiteflags
Quote:

doubles are both of int and float right? cool
Doubles are basically the same as floats, just bigger. Integers have nothing to do with either float or double.
Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last