In: Computer Science
There is a package, `beepr`, with a single function, `beep()`. Write a function with an input, `x`, that will call `beep()` when `x > 0`. You may assume that the `beepr` package has been loaded. Call your function `xgt0()`.
Here's the code feel free to ask any query related to this.
#immporting library beepr
library(beepr);
#declaring the function xgot0()
xgot0 <- function(x){
#checking if x >0 or not
if(x>0)
{
print("Beep sound is produced ");
beep(0);#producing random sound
}
else
{
print("Beep sound is not produced");
}
}
#taking input from user
x <- as.integer(readline("Enter the number x"));
#calling function
xgot0(x)
ScreenShot of result