Writing a function that takes three inputs and returns the smallest of them

maximum <- function()
{
  x <- as.integer(readline("Enter an integer x: "))
  y <- as.integer(readline("Enter an integer y: "))
  z <- as.integer(readline("Enter an integer z: "))
  
  max(x,y,z)
}

maximum()

I'm having issues with making the program work.. an y help anyone?

It is working fine for me. you just need to change min at place of max in your function.

minimum<- function()
  {
    x <- as.integer(readline("Enter an integer x: "))
    y <- as.integer(readline("Enter an integer y: "))
    z <- as.integer(readline("Enter an integer z: "))
    
    min(x,y,z)
  }
  
  minimum()

Does it ask the user to input those values when you run it?

Yes in console window you will have to type the numbers yourself and you will get the output in console again.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.