You are on page 1of 13

Department of Electronics &Telecommunication Engg.

, LGNSCOE

ysingtheFile
close a file whiclh is already open, we will use fclose(). As we hav already discussed
7taxof it
we will directly head over to the example.
lude <stdio.h
main(){
LE*file:
H= fopen("file2.txt", "w"):
jvitlfile,
"Hello! Welcome to Scaler academy.\n");
klose(tile);

which is to be
In this example. the file is the pointer associated with the file(file2.txt)
file and start pointing to
oxed. After closing the file the file pointer lost the reference of the
ULL.
Conclusion:

husimplement mploy ee
dataose manaqemenh us ing Aes,

st lab Questions
1. What is error handling in C?
2. What is files in C & its uses?
an array?
3. Write a prograin in C to read the file and store the lines into

|Page
NOrme' legasoini Rjendra Khad e
Tage No.
Date
Procal NO -

hot S e rror
handing in anguage
Chere are same other 0904s by mhich ermr
handingq Can be done in C language he
hender Ale "errorh" is MSed toprint the
prrors Using reHurn StOLement fncon

erhno ariaoeis_se Cutth the error Code

Alhot 'S Ale in

Text ile -
hese are the simples eLes a User Can
orecte cohen deaung cith a
Lsing any simple teXt editor
Use - dt is used for Storgge g aormahon

Ainary File ;
A bindry Ale stores informgton in the
eorm oA the bincry Dumber System and
hence occupies lesS
USe to Store any dato StorageSpace
alriteq eracqmm n o to read the ele &
S5+0 re he nes nto Qn

Progran
Fngme
a e the cantent
of lhe (\n print
: istlen
(hne ine
TZE Cil (Iine gets cEuhile
Fptr
3COnE%s"
s"fnome) %
Alenome
be to the pput f(" Print
i\n"
ninto eine
qnd le the Read \n\n FPrin
LSTZ]; name Char
[RST
2] Line char
(VOi)d nain tnt
deEineLSTZ
\28 define
String
Zh include<
K_stdb.h2 inctude k
S+dioh inalude< #
alrj
Telecommunication
Department of Electronics & Engg., LGNSCOL
Conclusion:

hus aoe e vatuae POsA'Y epression

Post lab Questions


1. Show in stack format as above & cvaluate: - 23 1 *+9
2. What is the time complexity of evaluation of post fix expression algorithm?
3. Show in stack format as above & evaluatc: *10 22+8/6*5+"

6| Page
Name;- Tejasini Rajendrq snade
Page No.
Date

PractCal No-09

Cnput
EXplanaHan
LE e exp is Conver+ed into

Consid er the espression.

2
5-C
5+6ck Erom
paPCperakor SeantS
2+3
Evalu
eCUt
5)
StoaK inPUsh &
2 2
OPeronds
OPêrC+Or
Ond the apply Stacl From
apea+orpop
t0 an its
Page No.
Date

hc tS the +imne complexiy Or


af eOS+Fix QXpression
evoluOHO D
(he Hme alQorhm
Department of Electronics &Telecommunication Engg., LGNSCOE

4 3

2 3

Step: 8

Repeat until allthe vertices have been visited


Tine Complexity
which has a complexity of O(n). n is number of
The program contains two nested loops each of
vertices. So the complexity of algorithm is O(n).

Conclusion:

hus ae imple ment DijKSHOs


Cuggritthm

Post lab Questions


I. Explain Dijkstra Algorithm with example.
2. Show the working of the Dijkstra's Algorithm on the given examples: -

100

A
30

60 3
2
\50 10

S|Page
Nome - Tejasoini gajendra Khade,
Page No.
Prac cu NO-Lo Date

Explain DsS+r Alqorithm coth example.


Dijksa's algorithm aa0S ths +O Aind he
araprnt diefers frOm the minimumSpoDnng
4ree hecaUSe the shor+es t distOnce betaeen
teaa eN VerHCeS miqht nOt inchude CLL the
VeriCes. OA he
graph
DijKstra's algorithm cooriks an the basis thet
any Sub poh B>o aA he sho+est path
A->0 peta)e e n e ces A and D ts cuso
e

Exarmple -

2,

Choase 5tarog certex and assign


Other de viCes
6

path length of the


ereX es.Ser adocent

2.

SPp

2
Date

2
Step VIII

Shaco the coorking OEhe Dsstr0S


on the qiven excmples agorth

6O

a) coSt

50 20
20 60
4 6 O

disore Ma+rix

ViS+ed
+eraHon - dis+ance
eilo)oolo
Vi'sited=

TtOratHon 8 4
nd
66
disránce

ViSited =

AteraHOn
O||0 50
dis+ance =

Visiteol

,th Tteoon
go60| fing) dis
distorce =

Visite=

You might also like