Perl language and by using VS Code: Write a program that reads a number, adds up the cube of all the digits, and displays the result. Run your code with the following test number:
1242
It should give 81.
Please include screenshots of your outputs.
Hey here is answer to your question.
In case of any doubt comment below. Please UPVOTE if you Liked the answer.
#!/usr/bin/perl
# your code goes here
use strict;
use warnings;
print "Enter a number :";
my $num = <STDIN>;
#You missed out to remove the entermark at the end
chomp($num); my $newnum = "0";
$newnum += $_*$_*$_ for split//, $num;
print $newnum;
Get Answers For Free
Most questions answered within 1 hours.