Need some help to find out the output of this Perl code

Asked By 0 points N/A Posted on -
qa-featured

Hi guys, Please consider the following code segment and tell me what are the values of @y and @z after executing the code segment

@num = (2,16,4,32);
@y = reverse(@num);
@z = sort{$b <=> $a} @num;

SHARE
Answered By 0 points N/A #93710

Need some help to find out the output of this Perl code

qa-featured

Hi Iris , hope the following steps will guide you in fixing of this issue.:..:

>Perl is an superb language and is very easy and coming to the program you have first declared the num variable with values as

you given as 2,16,4,32 in the program.

>The requirement is that to find the values of both y and z as you mentioned in the program next to the declaration of the variable

num in the code segment mentioned above.

>As in the program to find out the value of y is that to find out the reverse of the variable num and the output we get is not the

reverse as we will not get any error or any output for y value.

Z is the another variable to find out the sorting of the variable num as declared and the problem is that in this case too we will

get same as y as no output or no error in case of z in the program.

Thank you..:-)

Login/Register to Answer

Related Questions