#!/usr/local/bin/perl
use strict;
use warnings;
print "What is your name ? ";
my $name = <STDIN>;
print "Hi $name";
print "Enter a number: ";
my $num = <STDIN>;
chomp($num);
print "Even numbers below $num: ";
for(my $i = 1; $i < $num; $i++)
{
if($i%2 == 0)
{
print "$i ";
}
}
print "\n";
print "Odd numbers below $num: ";
my $j = 1;
while($j < $num)
{
if($j%2 != 0)
{
print "$j ";
}
$j++;
}
print "\n";
use strict;
use warnings;
print "What is your name ? ";
my $name = <STDIN>;
print "Hi $name";
print "Enter a number: ";
my $num = <STDIN>;
chomp($num);
print "Even numbers below $num: ";
for(my $i = 1; $i < $num; $i++)
{
if($i%2 == 0)
{
print "$i ";
}
}
print "\n";
print "Odd numbers below $num: ";
my $j = 1;
while($j < $num)
{
if($j%2 != 0)
{
print "$j ";
}
$j++;
}
print "\n";
No comments:
Post a Comment