R Program to find the largest of three characters using nested if


In this program, You will learn how to find the largest of three characters using nested if in R.


Find greatest among three characters

Character Is : A B C => C

Character Is : B D A => D

Example: How to find the largest of three characters using nested if in R

{
  ch1 <- readline(prompt = "Enter first Character :")
  ch2 <- readline(prompt = "Enter second Character :")
  ch3 <- readline(prompt = "Enter third Character :")

  if (ch1 > ch2) {
    if (ch1 > ch3)
      print(paste("Greatest is :", ch1))
    else
      print(paste("Greatest is :", ch3))
  } else  {
    if (ch2 > ch3)
      print(paste("Greatest is :", ch2))
    else {
      print(paste("Greatest is :", ch3))
    }
  }

}

Output:

Enter first Character :B
Enter second Character :A
Enter third Character :C
[1] "Greatest is : C"

Xiith is created for educational, experimental, and schooling purpose. Examples on Xiith are made easier to make a better or basic understanding. Tutorials, testimonials, and examples are continuously checked to avoid delusion, but we cannot take complete responsibility of all programs on Xiith. When you are operating this site, you have to agree to read and accept our terms of use, cookie and privacy policy.Copyright © 2020 by Xiith. All Rights Reserved. About us.