Computer Science, asked by Sunny7858, 1 year ago

Write a function RevText() to read a text file “ Input.txt “ and Print only word starting with ‘I’ in reverse order .

Example: If value in text file is: INDIA IS MY COUNTRY Output will be: AIDNI SI MY COUNTRY

Answers

Answered by dhaygude764
13

void RevText()

{ ifstream in ("Input.txt");

char word[25];

while(in)

{ in>>word;

if (word[0]=='I')

cout<<strrev(word)<<..;

else

cout<<word<<....;

}

Hope it helps

Answered by franktheruler
4

Answer :

note :  

strrev ( ) function is used to reverse a string.

cout is an output stream which is used to show output.

cin is an input stream which is used to take input.  

Input.txt is a text file according to the question.

void RevText (  )  // this is a function

{

ifstream Fin ( “ Input.txt ” );

char W [20];

while ( ! Fin.eof ( ) )  

{

Fin >> W ;

if ( W [ 0 ] == ’ I ’ )

strrev ( W );

cout << W <<  “  ”  ;

}

Fin. close (  ) ;

}

Similar questions