CS Electrical And Electronics
@cselectricalandelectronics

Develop a program to find the square root of a given number N and execute for all possible Input with appropriate messages. Note: Don’t use library function sqrt(n).

All QuestionsCategory: C LanguageDevelop a program to find the square root of a given number N and execute for all possible Input with appropriate messages. Note: Don’t use library function sqrt(n).
nikhil.d asked 3 years ago
2 Answers
nikhil.d answered 3 years ago

#include <stdio.h>
int main()
{
    float sqrt, temp, n;
    printf(“Enter a number\n”);
    scanf(“%f”, &n);
    sqrt = n / 2;
    temp = 0;
    while (temp != sqrt)
    {
        temp = sqrt;
        sqrt = (n / sqrt + sqrt) / 2;
    }
    printf(“The square root of the number is %f”, sqrt);
}

Anonymous answered 3 years ago

Note: Change the double inverted comma ( ” ) in the code to avoid an error.