Snippets

sironekotoro Perl入学式 2018 第2回 復習問題 even_or_odd.pl

Created by sironekotoro
#!/usr/bin/env perl
use strict;
use warnings;

# Perl入学式 2018 第2回 復習問題
# https://github.com/perl-entrance-org/workshop-2018/blob/master/2nd/practice.md
# 復習問題(even_or_odd.pl)

# 標準入力により数値を一つ読み込み, その数値が偶数なら"even", 奇数なら"odd" という文字を出力するeven_or_odd.plを作成しよう

print "INPUT some number > ";
my $input = <STDIN>;
chomp $input;

if ( $input % 2 == 0 ) {
    print "$input is even\n";
}
else {
    print "$input is odd\n";
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.