Calculate Square Root without using Math.h sqrt Function

C Programming Language / Command Line Arguments

677

Program:

#include<stdio.h>
#include<stdlib.h>

int main(int argc, char *argv[])
{
    if(argc==1)
    {
        printf("No arguments");
     return 0;
    }
    else
    {
        int n;
        n=atoi(argv[1]);
        float i=0.00;
        
        while(i*i<=n)
        {
            i=i+0.001;
        }
        
        i=i-0.001;
        printf("%.2f",i);
    }
}

Output:

37

6.08

Explanation:

Nope

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.