Computer Hope

Other Pages

Home
Site map
Computer help

Dictionary
News
Q&A
What's new

Tools

E-mail this page
Print Preview
Edit this page



 

Else if

Also known as elsif, else if is a conditional statement performed after an if statement that if true performs a function. Below is an example of an if, elsif, and else conditional statement in Perl.
  


#!/usr/bin/perl
print "Enter number: ";
my $number = <STDIN>;
if ($number <= 10) {
print "Your number is less than or equal to 10";
}
elsif ($number <= 50) {
print "Your number is more than 10 but less than 50";
}
else {
print "Your number is greater than 50";
}

The above example shows how elsif could be used to create an additional conditional statement and not just a simple if / else statement. This could also be extended adding as many elsif or else if statements as the program needed.

Not all programming languages are the same, although this above example used elsif, in a different language such as ANSI C you would use "else if".

Also see: Else, If statement, Programming definitions

 

Index

Category:
Dictionary

Related Pages:
E - Definitions

Resolved

Were you able to locate the answer to your questions?

Home - Computer help - Contact - Dictionary - Links
Link to Computer Hope - Bookmark Computer Hope