sqrt()
function in R Language is used to calculate the mathematical square-root of the value passed to it as argument.
Syntax: sqrt(x)
Parameter:
x: Any numerical value greater than 0
Example 1:
# R code to calculate square root of a number x1 <- 16 x2 <- 18 # Using sqrt() Function sqrt(x1) sqrt(x2)
Output:
[1] 4 [1] 4.242641
Example 2:
# R code to calculate square root of a number x1 <- 8.34526 x2 <- -18 # Using sqrt() Function sqrt(x1) sqrt(x2)
Output:
[1] 2.888816 [1] NaN Warning message: In sqrt(x2) : NaNs produced
Here, in the above code, NaN is produced because we passed a negative value in the sqrt() function.
Australia
UK
UAE
Singapore
Canada
New
Zealand
Malaysia
USA
India
South
Africa
Ireland
Saudi
Arab
Qatar
Kuwait
Hongkong
Copyright 2016-2023 www.programmingshark.com - All Rights Reserved.
Disclaimer : Any type of help and guidance service given by us is just for reference purpose. We never ask any of our clients to submit our solution guide as it is, anywhere.