You are on page 1of 2

<?

php
$file = fopen('source.txt', 'rb');
$newfile = fopen('target.txt', 'wb');
while(($line = fgets($file)) !== false) {
if(strpos($line, 'user.php') !== false) {
fputs($newfile, $line);
}
}
fclose($newfile);
fclose($file);
?>

print("This program 'is' designed to find the average of n numbers you input\n")

first_question = 'Would you like to enter a number? (type "yes" if you do)\n\n'
second_question = 'Would you like to enter another number after this? (type "yes" if
you do)\n'

sum_of_numbers = 0
counter = 0
if input(first_question) == "yes" :
sum_of_numbers += int(input("Enter your number here:"))
counter += 1
while input(second_question) == "yes" :
sum_of_numbers += int(input("Enter your next number here: "))
counter += 1
print("Your average is " + str(sum_of_numbers/counter))

@array(4,9,1,3,2);

if(($array[0] > $array[1]) && ($array[0] > $array[2]) && ($array[0] >
$array[3]) && ($array[0] > $array[4])){
print "$array[0] is the largest number in the array\n";
}elsif(($array[1] > $array[0]) && ($array[1] > $array[2]) &&
($array[1] > $array[3]) && ($array[1] > $array[4])){

print "$array[1] is the largest number in the array\n";


}elsif(($array[2] > $array[0]) && ($array[2] > $array[1]) &&
($array[2] > $array[3]) && ($array[2] > $array[4])){

print "$array[2] is the largest number in the array\n";


}elsif(($array[3] > $array[0]) && ($array[3] > $array[1]) &&
($array[3] > $array[2]) && ($array[3] > $array[4])){
print "$array[3] is the largest number in the array\n";
}elsif(($array[4] > $array[0]) && ($array[4] > $array[1]) &&
($array[4] > $array[2]) && ($array[4] > $array[3])){

print "$array[4] is the largest number in the array\n";

You might also like