Computer Science, asked by heeras8246, 1 year ago

Write a perl program to find average of numbers entered in user defined list

Answers

Answered by BrainlyTech
15

\textbf{ Hello Friend!! }

\textbf{ I'm here to help you with your question. }

\textbf{ Lets get started! }

\textbf{ Here is what I got for you today }

#usr/bin/perl


use strict;


use warnings;



my $a; #variable declaration


my $b; #variable declaration


my $c; #variable declaration


my $avg; #variable declaration


my $x; #variable declaration


my $y; #variable declaration


my $z; #variable declaration


my $results; #variable declaration


my $number; #variable declaration



$a = 2; #number 1


$b = 6; #number 2


$c = 7; #number 3



$avg = avg($a,$b,$c); #Three variables to be averaged



 sub avg {


 ($x,$y,$z) = @_; #Store variables in array


  $results = ($x+$y+$z)/3; #Values stored added, and divided for average


  return $results; #return value



          }



  print "$avg\n";


  exit;


\textbf{ Hope this helps you! }

\boxed{ Be Brainly! }


BrainlyTech: 1 sec
BrainlyTech: Sorry i had to edit so many times i found mistakes in my ans but i fixed all the errors and hope this helps you
Similar questions