If anyone knows the answer
Posted: 2008-02-12 01:50:58
Dear Friends,
If anyone knows the answer for below mentione query, pls post answer.
#!/usr/bin/perl
@data=N;
$sum=0;
print"enter the required No. of numbers to be inputed : f";
$N=<STDIN>;
print"enter the number";
for($i=0;$i<$N;$i+=1)
{$data[$i]=<STDIN>;
# chomp $data[$i];
$sum=$sum + $data[$i];}
# for($j=0;$j=$data[$i];$j+=1)
print"the entered numbers are",@data,"\n";
print"sum of the number:",$sum,"\n";
print"Average value the numbers:",$sum/$N,"\n";
@sorting=sort(@data);
$lengt=@data;
for ($j=0;$j < $lengt;$j++)
{# print $sorting[$j],"\n";
}
$X= (@sorting[($j-1)/2]+ @sorting[$j/2])/2;
print"the median is :$X";
QUE: the median is the middle value if the numbers have been sorted in
ascending order (for even numbers of values it is your choice to pick
the first or second of the middle numbers.
If anyone knows the answer for below mentione query, pls post answer.
#!/usr/bin/perl
@data=N;
$sum=0;
print"enter the required No. of numbers to be inputed : f";
$N=<STDIN>;
print"enter the number";
for($i=0;$i<$N;$i+=1)
{$data[$i]=<STDIN>;
# chomp $data[$i];
$sum=$sum + $data[$i];}
# for($j=0;$j=$data[$i];$j+=1)
print"the entered numbers are",@data,"\n";
print"sum of the number:",$sum,"\n";
print"Average value the numbers:",$sum/$N,"\n";
@sorting=sort(@data);
$lengt=@data;
for ($j=0;$j < $lengt;$j++)
{# print $sorting[$j],"\n";
}
$X= (@sorting[($j-1)/2]+ @sorting[$j/2])/2;
print"the median is :$X";
QUE: the median is the middle value if the numbers have been sorted in
ascending order (for even numbers of values it is your choice to pick
the first or second of the middle numbers.