Hi guys, im new at C, idk whats wrong with my program, can anyone help me out? or maybe I should go ask /b
?
Square root
Other urls found in this thread:
...
>a square root method
>Copyright Armando
>mexican coding
[math] \displaystyle
\sqrt {x^2} \ne \pm x, \quad \sqrt {x^2} = \left | x \right |
\\
|x| =
\begin{cases}
\;\;\; x & ,x \geq 0 \\
-x & ,x < 0
\end{cases}
[/math]
This is correct.
use a recursive binary search so that ita n log n
Your code can be simplified:
Input n
Print n and n
>Copyright © 2017 Armando.
>Copyright © 2017 Armandillo.
>Armando
lol how much money do you want for me to license your code?
How about we see your C implementation of square root?
I know next to nothing about C but I can tell you're over-engineering.
Here you go.
[code]
#include
int main(void)
{
int n = 144;
int i;
for (i = 1; i
sqrt()
Read C spec, fix the width of your variables or the shift. Anyway, use sqrt from math.h because you won't outperform it on most architectures and it's portable.
Stop being retarded and use Scheme instead. It works and is much more beautiful.
(define (squareroot x)
(define (iteration currentvalue iterationsleft)
(if (= iterationsleft 0)
currentvalue
(iteration (/ (+ currentvalue (/ x currentvalue)) 2) (- iterationsleft 1))))
(iteration 1 10))
This. Or use the power function to 0.5.
>has never coded in his life
these guys too:
Yeah it's auto generated. Still looks retarded.
>printf("raiz(%d)=%d",n,n);
>n
and another
>n
>Xcode
real men use vim and the command line
well spotted
There are also some short vs. int gotchas. Make everything int for simplicity.
I dont know C, but ive been learning python. Do you need to import a math library to use? In python you have to import math to use sqrt()
cool story bro