Professional Documents
Culture Documents
Labsession3-Filehandling 3293
Labsession3-Filehandling 3293
1.WAPwhichdisplaysitssourcecodeontheoutputscreen.
2.WriteaprograminCwhichtakesatextfile'snameascommandline
argumentandreadthefirst
word,displaysitandskipnextnwordswherenisthelengthoflast
wordyoujustdisplayed.Repeat
untilyoureachendoffile.
3.Writeaprogramtoreadafileanddisplayitscontentsalongwith
thelinenumberbeforeeachline
andtotalnoofcharacteraftereachline.
SampleOutput1:
<onconsole>
1welcometoweek4ofC
module.30
2thisisyourassignment.24
......................................
.......................................
<end>
4.1WAPthatacceptsafileasinputandprintsonlythoselinesof
thefilewhichcontainsonlyone
vowel.Makenecessaryassumptionswherevernecessary.
4.2Toencrypt/decryptamessageusingashiftciphereachcharacter
ofthemessageisshiftedbya
predeterminedvalue(calledkeyoroffset).Encryptionanddecryption
aredefinedasinverseoperation
ofeachother,i.e.,decryptionofaencryptedmessageresultsthe
originalmessage.
Writeaprogramtoencrypt/decryptafileusingshiftcipher.The
programshouldaccepttwoarguments
'e'or'd'(forencryptionanddecryptioncorrespondingly)anda
integerkeyvalue(shiftvalue).
5.WriteaprograminC
toaccept3commandlineargument,twooperands(integers)andone
arithmeticoperator.Performtheoperationontwooperandsandstore
theresultinresult.txttextfile.
Asktheuserifhewantstocontinue.Ifyesthenagaininputthree
symbols(twointegersandone
arithmeticoperator)andappendtheoutputinresult.txtfile.