Page 80 - C++
P. 80
Ans. void RevText( )
{
ifstream Fin(“Input.txt”);
char Word[20];
while(!Fin.eof())
{
Fin>>Word;
if(Word[0]==’I’)
strrev(Word);
cout<<Word<< “ ”;
}
Fin.close( );
}
OR
int Countalpha()
ifstream ifile ("BOOK.txt");
char ch;
int count =0;
while (! ifile.eof())
{
ifile.get(ch); Ifele.get(ch);
if(isfower(ch))
count ++;
}
ifile.close();
return (count)
}
(½ Mark for opening Input.txt correctly)
(½ Mark for reading each Word from the file)
(½ Mark for checking the word starting with ‘I’ )
(½ Mark for reversing and displaying the word)
OR
(½ Mark for opening Input.txt correctly)
(½ Mark for reading each character from the file)
(½ Mark for checking the lower character )
(½ Mark for displaying the count)
(b) Write a function in C++ to search and display details, whose destination is (3)
“Cochin” from binary file “Bus.Dat”. Assuming the binary file is
containing the objects of the following class:
class BUS
{ int Bno; // Bus Number
char From[20]; // Bus Starting Point
16