Search



Monday, 16 February 2015

Square Root

In this program, # is a preprocessor directive ,  whereas #include<math.h> is used to
extract the functions already created in file math.h (eg:- sqrt , pow , sin etc..) .
For variable double x , %lf is used to grab the value.Line result = sqrt(x) stores 
the square root of x in result which is displayed in last line .  

----------------------------------------------------------------------------------------------------------------------------------------------------

Program for Square root.

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{   double x , result;
    clrscr();
    printf("\n program to calculate square root of any no.");
    printf("\n\n enter x : ");
    scanf("%lf",&x);
    result = sqrt(x);
    printf("The square root of %lf is --> %lf\n", x, result);
    getch();
}



No comments:

Post a Comment

Guys if you think something is wrong or should be edit than please do comment.