Who knows Perl?

Below is a program. What is the output? (Paper may be required)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
my $doge = 5;
my $cat = 6;
my $redman = 3;
my $p = 0;
my $var1 = 2;
my $loop = 10;
for(my $i=0; $i<$loop;$i++){
if($var1 == 2){
$p=($doge * $var1) * $redman;
$var1=0;
} else {
$p+=$redman * $cat * $doge-$i;
}
}
print $p,"\n"; 


The answer is 795.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

W Tyson
Dec 10, 2017

If you put it in a perl compiler, this is the output. Following what happens in the code and doing what the code says to do to the variables, when $p is printed, it will print 795

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...