Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7190

Php crashes when mean, median, and mode are reached

$
0
0

Me and my group are making a research paper on Pascal and Php, and for the last step we have to make a simple program that calculates the floating point numbers into mean, median, and mode. However, the program refuses to run on my partner's NetBeans PHP IDE along with my Visual Basic.

<?php        $Numbers= array(20);        $Mean=0;         //these functions are called          getNumbers();         calMean();         NumbersaboveMean();         calMedian();         calMode();         Mode();        //this function gets the numbers from the user        function getNumbers()        {                  $temp=0;                   echo " Enter up to 10 float point numbers ";             for( $n=0; $n<20; $n++)        {        $Number[$n]=(float)readline('Enter a number: ');//gets the number from the user            }         //This arranges the numbers in order from least to greatest         for( $n=0; $n<20; $n++)        {               $temp=$Number[$n];               $Number[$n]=$Number[$n+1];               $Number[$n+1]=$temp;                               }         }        //This function calculates the mean        function calMean()     {        for( $n=0; $n<20; $n++)        {           $sum=$sum+$Number[$n];                     }        $Mean=$sum/(20);         echo "The mean of your numbers is " + $Mean;     }     // funciton determines how many numbers are above the mean       function NumbersaboveMean()     {         $track=0;         for($n=0;$n<20;$n++)        {           if($Number[$n]>$Mean)           {                $track++;           }        }           echo " There are " + $track +" numbers above the mean.";       }        //determines what the median is     function calMedian()     {          $median=Number[10];            echo "The median of your numbers is " + $median;              }     //this function determines what the mode is      function calMode()     {                 $mode=0;         $count=0;         $count2=0;         $md2=0;         for($n=0;$n<18;$n++)        {           if($Number[$n]===$Number[$n+1])           {               $count2++;                            }                    if(count==count2)           {               $count=$count2;               $count2=0;               $md2=1;           }           else if(count<count2)           {               $mode=$Number[$n];               $count=$count2;               $count2=0;           }                }     }       //determines if there is 1 mode or more        function mode()        {           if(md2>0)           {               echo "There is more than 1 mode.";           }         else         {             echo "The mode is " + mode;         }        }        ?>

When I run it, I get to about 10+ loops of inputting numbers before it crashes with "Code has exited with -1 (FFFFFF~~~) (something something i will update it when I get my pc back in a few hours.

To be honest, we really don't need a fix to the not running we just want to know if the code does it we want it too.


Viewing all articles
Browse latest Browse all 7190

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>