sqrt function in C programming language

In this tutorial, we will discuss sqrt function in C programming language

Description

description of sqrt  function in C programming  language:

The sqrt()  function in C programming language  returns the square root value

sqrt() : In C Programming Language, this   is used to find square root of the given value

 

Declaration

declaration sqrt() min C programming language

double sqrt (double x);

parameters or Argument

parameter of sqrt()  in C  language is:

x- x is  the parameter or argument of this function for calculating the square root of x

 

Returns

when you pass a value for x, this function returns the square root value of x

 

Required Header

In thic Language, the required header file for sqrt() is

#include <math.h>

Example

The following example shows the usage of  sqrt() function

 

sqrt function in C

Program 1

#include <stdio.h>
#include <math.h>
int main()
{

    printf("sqrt value of 3 is %f\n",sqrt(3));
    printf("sqrt value of 4 is %f\n",sqrt(4));
    printf("sqrt value of 6 is %f\n",sqrt(6));
    getch();
    return 0;
}

When the above program is compiled, it will produce the following result

sqrt value of 3 is 1.732051

sqrt value of 4 is 2.000000

sqrt value of 6 is 2.449490

 

Program 2

#include <stdio.h>
#include <math.h>
int main()
{
    //define temporary variable
    double val1;
    double result;
    printf("Enter the number for val1 :");
    //get input from user
    scanf("%lf",&val1);
    //calculate sqrt
    result=sqrt(val1);
    //Display sqrt value
    printf("sqrt value is: %lf\n",result);
getch();
    return 0;
}

When the above program is compiled, it will produce the following result

Enter the number for val1: 25

sqrt value is: 5.000000

 

Similar Functions

Other C programming language functions that are  similar to the cosine function      

cosh function   in C  language                               

sinh function in C language

tanh function in C language

abs function in C language

floor function in C language

ceil function in C language

round function in C language

sqrt function in C language

pow function in C language

exp function in C language

log function in C language

log10 function in C language

trunc function in C language

 

 

suggested for you

Function in C language

User defined function in C language

Arithmetic functions in C Language

String function in C language

                                                                               

pow function in C programming Language
log10 Arithmetic function in C Language
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago

Java program to check odd or even using recursion

Java program to check odd or even using recursion In this tutorial, we discuss a…

2 months ago