+2 votes
in Computer by kratos

Following is the code to count no. of vowels from a text file. Fill in the blanks so that this code can work:

<? php

$f = ___(“exam.txt”, “r”);

$vowel = 0;

while(___($f))

{

$ch = ___($f);

$ch = strtolower($ch);

if($ch == ‘a’ ||$ch == ‘e’||$ch == ‘i’ ||$ch == ‘o’ ||$ch == ‘u’ )

$vowel = $vowel +1;

}

echo “Number of vowels:” . $vowel . “
”;

__($f);

?>

1 Answer

+3 votes
by kratos
 
Best answer

<? php

$f = fopen(“exam.txt”, “r”);

$vowel = 0;

while(!feof($f))

{

$ch = fgetc($f);

$ch = strtolower($ch);

if($ch == ‘a’ ||$ch = =‘e’||$ch = =‘i’ ||$ch = =‘o’ ||$ch = =‘u’ )

$vowel = $vowel +1;

}

echo “Number of vowels:” . $vowel . “
”;

fclose($f);

?>

...