Categorised Menu List

Conditional IF Statement 

Simple IF, Complex IF and Compound IF Statements)

without IF, there would not be any need for BRAIN...

 

I believe no much introduction is required for IF statement, because, when we have to decide between two values, we use IF Condition or IF statement (Excel Usage).

 

eg: if you have a spreadsheet with total marks, and say for example, 50 marks is the cut-off mark, then we put a condition to check, if, that particular cell's value, is Greater than 50 or not, if it is greater than 50, the current cell content should be PASS else the current cell content should be FAIL.  before, you continue, please consider to check the given examples, so that they may prepare you to learn the following content, in-fact it is good practice to study the questions first and then continue onto comprehension

gallery/simpleif
gallery/simpleif_eg1
gallery/simpleif_eg2

Compound IF Statement

When IF statement is used with Logical Operators,
it is generally called Compound IF Statement.

Situation:
Taking the same Marks example, Management want to concentrate more on the students who are on the border of pass mark of 50, so that a bit more concentration on these students will raise the pass percentage of the school, hence to get students whose marks are greater than 35 and less than 50,

then: Write the following statement, for students with marks between 35 and 50. 

gallery/between35and50
gallery/compoundif
gallery/compoundif_eg1
gallery/compoundif_eg2
gallery/or_situation_01
gallery/or_situation_02

Nested IF Statement

Simple IF Statement

When an IF statement is used within another IF Statement, it is called Nested IF Statement. This can accommodate any number of conditions within another condition, including Logical operators.

Situation:
Taking the same Marks example,
Now, the task is to Grade the students based on the marks in Col D (Total Marks). The classification would be as: students securing 75 marks and above are in Grade A, less than 25 marks are in Grade D, between 50 and 75 are with Grade B, between 25 and 50 are with Grade C.
As the situation demands, one can have any number of If statements required (Excel 2007 and later can contain up to 64 nesting levels, function can handle 30 arguments, which implies to testing 30 different conditions (in theory, I did not check) 

gallery/complexif
gallery/finalview

Examples for Practice

The following examples can be used either in spreadsheet to check/validate the above given IF Statement, or can be used in programming...

  1. Check if the given number is greater than zero or less than zero.
  2. Check if the given number is Odd number or even number.
  3. Check, if the given number is prime numbe or not, display message accordingly.
  4. Check if the given alphabet is a vowel or consonant.
  5. Check if the given number is greater than 50, if greater than 50, check if it is greater than 75, if it is not greater than 50, check if that number is less than 25, if all fails, check if the given input is a number or not.
  6. Check if the given number is greater than zero or less than zero or equal to zero.
  7. In a set of three given numbers, which of them is greater than the rest, which of them is less than the rest.
  8. Check if the first letter of a given input is vowel.
  9. Check if given two number's sum is postive or negetive or equal to zero.
  10. Given three numbers, print them in asceding order.
  11. Given three numbers, also in descending order.
  12. For a given input, check if the number is divisible by 2 or 3 or 4.
  13. Check if the given year is a leap year.