R Program to find the largest of three numbers using nested if
In this program, You will learn how to find the largest of three numbers using nested if statement in R.
Find Greatest among three Numbers
Numbers Is :10 20 40 => 40
Numbers Is :30 20 10 => 30
Example: How to find the largest of three numbers using nested if in R
{
x <- as.integer(readline(prompt = "Enter first number :"))
y <- as.integer(readline(prompt = "Enter second number :"))
z <- as.integer(readline(prompt = "Enter third number :"))
if (x > y) {
if (x > z)
print(paste("Greatest is :", x))
else
print(paste("Greatest is :", z))
} else {
if (y > z)
print(paste("Greatest is :", y))
else{
print(paste("Greatest is :", z))
}
}
}
Output:
Enter first number :3
Enter second number :2
Enter third number :55
[1] "Greatest is : 55"