Conditional
Conditional
Alternatively referred to as a conditional expression and conditional processing, a conditional statement is a set of rules performed if a certain condition is met. It is sometimes referred to as an If-Then statement, because IF a condition is met, THEN an action is performed.
For example, consider the following textual example of a conditional statement.
IF a value is less than 10, THEN display the words "Value is less than 10" on the screen.
The example above is how a conditional statement might be interpreted by the human brain. Using a computer programming language, the conditional statement above could be written like the example statements below.
if ($myval < 10) {
print "Value is less than 10";
}
In this example, if the variable $myval is less than 10, the software program prints "Value is less than 10" to the screen.
if ($myval == 10) {
print "The value equals 10";
}
else {
print "Value is not equal to 10";
}
In this example, if the variable is exactly equal to 10, it will print "The value equals 10" to the screen. Otherwise, it will print "Myval is not equal to 10" to the screen.
if ($myval > 10) {
print "Value is greater than 10";
}
elsif ($myval < 10) {
print "Value is less than 10";
}
else {
print "The value equals 10";
}
Finally, this last example will print one of three messages to the screen, depending if the value is greater than 10, less than 10, or equal to 10.
What is an Operating System? » Computer Shortcut Keys and their Functions » Keyboard Function Keys » Computer Basics - Hardware - Software - Parts
Short Stories for Kids - Moral Stories – English Short Stories for Children - Moral Stories
for Kids - Stories for Kids - Funny Story for Kids - Scary Stories for Kids - Really Funny Short Stories - Bedtime Stories
Proverb Stories
Powerful Motivational Quotes for Students » Success Quotes » English Short Stories for Kids
Cabin Crew Jobs & Career Advice » Secretary Job Description » Receptionist Job Description » Top 100 Interview Questions and Answers » How to Prepare for an Interview » How to Write a CV » How to Choose a Career » Computer Shortcut Keys and their Functions
Scholarships in Australia » Scholarships in Austria » Scholarships in Belgium » Scholarships in Canada » Scholarships in Germany » Scholarships in Ireland » Scholarships in Italy » Scholarships in Japan » Scholarships in Korea » Scholarships in Netherlands » Scholarships in Switzerland » Scholarships in UK » Scholarships in USA
Scholarships for Study in Africa » Scholarships for African Students » Undergraduate Scholarships » African Women Scholarships & Grants Scholarships for Study in Africa » Scholarships for African Students » Undergraduate Scholarships » African Women Scholarships & Grants Scholarships for Study in Africa » Scholarships for African Students » Undergraduate Scholarships » African Women Scholarships & Grants Short Stories for Kids - Moral Stories – English Short Stories for Children - Moral Stories for Kids - Stories for Kids - Funny Story for Kids - Scary Stories for Kids - Really Funny Short Stories - Bedtime Stories
Proverb Stories
Powerful Motivational Quotes for Students » Success Quotes »Scholarships in UK » Scholarships in USA Scholarships in UK » Scholarships in USA Scholarships in UK »
Success Quotes »Scholarships in UK » Success Quotes »
Click here to post comments
Join in and write your own page! It's easy to do. How? Simply click here to return to Computer Basics FAQ.