[C Language] finding the square root of a number

Published by aakai1056 - Last update on October 1, 2009 04:54 PM by aakai1056

[C Language] finding the square root of a number




Intro



A simple C program allowing you to find the square root of a number.


#include <math.h> 
#include <stdio.h> 

int main(void) 
{ 
double x = 4.0, result; 

result = sqrt(x); 
printf("The square root of %lf is %lfn", x, result); 
return 0; 
} 

Notes

  • In this code we make use of the sqrt function, more information available on :
  • Thanks to [TECH] from the forum for this tip.