1.

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 . “<br>”;__________($f);?>

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 . “<br>”;

fclose($f);

?>



Discussion

No Comment Found

Related InterviewSolutions