C programming
C programming
Assianment
A400]A0552
Wite (-Proyam how
to nd many timg each Key
element i Preyent in an artay.
t incu de<stdio:h>
+in du deeCotio .h>
veid man ()
int
clrscrc);
Print(Enter n value i
Acan? (.Q ".
a)
{forli=l;icen;i++)
Beant(%d
"axca):
Pvintf
for
("arr
ay
(i=l;i=nsit)
elements are ; t
{
}
Prtt Enter a Ky: )
(n
Print
t++;
key element found at td,i);
it (t)
Printf (^key plement mot feund):
(ttitnasiglei)ye
Outrut:
Enter
4 elementa 1 13
array elements ue s 1 1 3
an
#ineude<stdio.h>
void main ()
int
apo]:,i,kn;
Print? (Enter st3e3 "):
for
(io;fenzít+)
(at3- a1)
n--)
j--5
hint(nAtu elininatfny
dupliaty
toor (t-osfeng i++)
Pyint("td", a(1);
(0cio icv
}
OutRit:
Enter ize :5
Enter 5 elements % 51
Ater elininadig dupliatea i :5113
3) ite c-Proram to fnd noof bords, ns, chaaetory
a c-Projam
in ven tring.
#inculeetdo.h
#mcudeestte
void main ()
h>NeAeeonw)in
Long cha, lword,ine;
int c,lag
charo;
Line = Word o;
Print Fnter the
chatt}
lne tt
else
}
n No.of Words d", word)
intt ("No.of lines d", ne),
Aint (\n No.of characters 4",cha)
Otput%
9
Enter the hing row
1: JNTVA College
Anantapur
9
Noof charattey-
21ll
()
)wite (-Projram to Bort aray o tringa by yang
char
int ij:
stings
[s][aoo], tempro) ;
for(t-eg ie5;it);
{
fr(ieijss;jt)
{
stror(temf,stinyca);
stite
(4htny().temp)1
tor (?so;
iz5;i++)
}
Outpits
Enter 5
zebya
dot
Cat
elephant
ant
Borted tviry a;
ant
Cat
do
elephant (ttiictist)
zebya
5) write a C-Proaramn to read 2 terent strtnsg and
c-
Count
ttj
temp +=Len
Yeturn Count:
}
ivnt
main C)
tratrcHPn(tra,
in='lo';
Pyitk The empt,No
n seiond 3trig is otcurene found \n.
Ar2,0ceurs, tr):
O utput
Enter
Enter
te frt
the relond
pting
hing gCat
:Cat dag Cat
nclude<tio.h
vofd
man ()
FlLE * P;
Char
Nametaol:
Printt(\nEte e marne to Cveate ");
frl-fopen(t name,'w"
Printt ("Fle
Created
Auccgafully. );
Patc('a',tp):
Pate( 8' tr);
Putc ^e:
Nintt (" n Data wten fucystully.");
fose (PF);
fp-fpen (PName,"y),
A Bc
wite wite and vead tert into a
a c-Proram to
+ include< sto.h>
tvuct u dent
int yl;
Char name (2s);
void main ()
FtlE *$P:
chay ch;
tvut sudent
fp Popen ("shdert
-informatfon. txt", "w):
do
Pvint Roll no
while(iead(43 ,Mgeat
\n ")
(0),1.) >0)
Printdt3\n", 3roll,fname)3
fclope ()3
Roll No% 55
Name Kartkaya
Want to add another ddata
N
(y):
Data written sutcey fully 3
Roll Name
)11nitl
559 sosh
Karthikey,
(m) wvit a c-Program to oPy lontents oone #le to anothe
ele.
#includec stdiahs
Void main C)
FîLE *fPA,*P2;
char ch ;
mt(Enter the tet wth Q at exdg );
P -fopen ("Zample
1-tx*","w)
hgetchar():
wkle (eh-'a)
Chgetchar)
Pate(hitra);
fdae (Pr):
PA-tePen(ample
1.txt"):
4pa -fofRn ("ampleitxt""w);
Pate (chtra);
Putc (ch,tra);
fclose (PP2);
fPa -fopen ("amplea.tx+",)
{
Patt (ch,stleut):
}
outPat: