R Lang

R Program to find the largest of three characters using nested if2 min read

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

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




Output:

The code first reads in values for ch1, ch2, and ch3 from the user and stores them as strings. It then enters a series of if statements which compare the values of ch1, ch2, and ch3 and print the largest value to the console.

The first if statement checks if ch1 is greater than ch2. If it is, the code enters the second if statement which checks if ch1 is also greater than ch3. If it is, the code prints a message saying that ch1 is the largest. If ch1 is not the largest, the code enters the else block and prints a message saying that ch3 is the largest. If the first if statement is not true, the code enters the second if statement which checks if ch2 is greater than ch3. If it is, the code prints a message saying that ch2 is the largest. If neither of these conditions are true, the code enters the else block and prints a message saying that ch3 is the largest.

It is important to note that this code compares the characters based on their ASCII values. ASCII (American Standard Code for Information Interchange) is a character encoding standard that represents letters, numbers, and other symbols as integers. ASCII values are used to represent characters in computers and other devices, and they can be compared using the same operators that are used to compare numbers.

Leave a Comment