Question: write in c 2. Write a function that computes the square root of a number. The square root of a number x can be approximately
2. Write a function that computes the square root of a number. The square root of a number x can be approximately computed as follows. First guess that the square root of x is 1. Then repeatedly get the next guess from the last guess using the rule next = 0.5(last +x/last) where last is the last guess and next is the next guess. Repeat ten times using a loop and the tenth guess will be approximately the square root. The function prototype is double compute_sqrt (double x). The function computes the square root of x and returns the square root. 3. Write a function that decides whether a number is a prime or not. A prime number is a number that is divisible only by 1 and itself. The function prototype is int is_prime (int n). The function returns true if n is prime and returns false otherwise. Write another function that displays all prime numbers less than or equal to a number. The function prototype is void display_primes (int n). The function displays all prime numbers less than or equal to n. Note that the display_primes function calls the helper function is_prime
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
