Q5. Write a function RevText() to read a text file " Story.txt" and Print only word
starting with 'l' in reverse order . Example: If value in text file is: INDIA IS MY
COUNTRY Output will be: AIDNI SI MY COUNTRY.
Solution
Answers
Answered by
2
Answer:
void word_count ()
{
ifstream i;char ch[20];int c=0;
i.open("opinion.txt"); while(!i.eof())
{
i>>ch;
C=C+1;
}
cout<<"Total number of words present in the text file are: "<<c;
}
Answered by
3
def revtext():
f=open("Story.txt".'r')
s=' '
while True:
d=f.readline()
if not d:
break
else:
m=d.split()
for i in m:
if i[0]=='i' or i[0]=='I':
s=s+' '+(i[::-1])
else:
s=s+' '+i
print(s)
s=' '
revtext()
Attachments:
Similar questions