You are on page 1of 2

Assignmentofarray

1. Notes:
2. Ifyouareintelligentenough,youcanavoidrepetitivecodeandwritea
groupoffunctioninasingleprogram.
3. Trytowriteefficientcode(lessexecutiontimeand/orlessspace)
4. Due date to submit to Class CR is Monday (11042016) and CR will
submitmeonTuesday(12042016).

1. WriteaCprogramwhichread10integersfromuserandprintallpairwhose
sumis70.
2. WriteaCprogramtoreadmarksof50studentsrangedbetween0and10and
findfrequencyofeachmark.
3. WriteaCprogramtocalculatemean,varianceandstandarddeviationofsorted
nfloatingpointvalues.
intarr_mean(inta[],intn)
intarr_varience(inta[],intn)
intstd_dev(inta[],intn)
4. WriteaCprogramwhichreadsalistofNnumbersandfindsthelargestand
second largest of them. User needs to write a function arr_largest() which
acceptstwoarguments(arrayandno.ofvaluesinthearray)andreturnlargest
value.Similarly,providearr_s_largest().
intarr_largest(inta[],intn)
intarr_s_largest(inta[],intn)
5. WriteaCprogramtoperformlinearsearchinanarrayof n elements.User
needs to write a function linear_search( ) which accepts three arguments
(array,no.ofvalues,andvaluetobesearchedinthearray)andreturnits
position,ifvalueisfoundotherwisereturn1.
intlinear_search(inta[],intn,intval)
6. WriteaCprogramtocountno.ofoccurrencesofaparticularinanarrayof n
elements. User needs to write a function linear_search_1( ) which accepts
threearguments(array,no.ofvalues,andvaluetobesearchedinthearray)
andreturnthecount.
intlinear_search_1(inta[],intn,intval)
7. WriteaCprogramtoperformbinarysearchinasortedarray.Userneedsto
writeafunctionbinary_search()
intbinary_search(inta[],intval,intlow_index,inthigh_index)
whichreturnitsposition,ifvalueisfoundotherwisereturn1.low_indexand
high_indexarelowerandupperboundofarray,respectively.
8. WriteaCprogramtosortanarrayofnelementsusingbubblesort.Userneeds
towriteafunctionbubble_sort()whichacceptstwoarguments(arrayandno.
ofvalues)andreturnnothing.

voidbubble_sort(inta[],intn)
9. Repeatexercise7forselectionsort.
10. Repeatexercise7forinsertionsort.
11. WriteaCprogramtosortanarrayof n elementsinsuchawaythatalleven
valuesprecedesoddvalues.
voidsort_1(inta[],intn)
12. WriteaCprogramtosortthefirsthalfofanarrayintheascendingorderand
theotherhalfofthearrayinthedescendingorder.
voidsort_2(inta[],intn)
13. WriteaCprogramtomergetwosortedarraysandstoreinto3array.
voidsort_1(inta[],intm,intb[],,intn,intc[])
14. WriteaCprogramtoinsertavaluevalatpositionpinanarrayofnelements.
voidarr_insert(inta[],intn,intval,intp)
15. WriteaCprogramtoinsertavalue val asortedarrayof n elements.(Hint:
firstsearchvalueusingbinarysearchtheninsertthevalue.)
voidarr_insert_1(inta[],intn,intval)
16. WriteaCprogramtodeleteavalue val (firstoccurrence)fromanarrayof n
elements.
voidarr_del(inta[],intn,intval)
17. WriteaCprogramtodeleteavaluefrompositionpinanarrayofnelements.
voidarr_del_1(inta[],intn,intp)
18. WriteaCprogramtocountallduplicateelementsinanarrayofnelements.
intarr_dup_count(inta[],intn)
19. WriteaCprogramtodeleteallduplicateelementsinanarrayofnelements.
voidarr_dup_del(inta[],intn)