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"