1 Replies - 2363 Views - Last Post: 21 August 2012 - 08:09 AM Rate Topic: -----

#1 aresh   User is offline

  • It's a 16-Bit World!
  • member icon

Reputation: 273
  • View blog
  • Posts: 4,258
  • Joined: 08-January 12

Nth Root Calculator

Posted 10 August 2012 - 10:35 AM

Description: This function will return the Nth root of any number
#include<stdio.h>
#include<math.h>

double Square_Root(double number, double root) // The first argument is number, and the second is which root we have to find
{
    double e = 2.7182818284; // Define "e", ie, Euler's Number
    return pow(e, log(number)/root); // Calculate the Nth root of the number
}

//Example usage

int main()
{
    printf("%f",Square_Root(4,2)); // Print 2nd root of 4
    return 0;
}


Is This A Good Question/Topic? 0
  • +

Replies To: Nth Root Calculator

#2 v0rtex   User is offline

  • Caffeine: db "Never Enough!"
  • member icon

Reputation: 223
  • View blog
  • Posts: 773
  • Joined: 02-June 10

Re: Nth Root Calculator

Posted 21 August 2012 - 08:09 AM

Useful snippet!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1