0 ratings0% found this document useful (0 votes) 33 views32 pagesCP Important Question Bank Which Can Come
Question bank of CP given by the teacher important question
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
7 ; —— No 2 -
= Al orithra: ae ia
_ Step t: Stacks eee 7 —
— Step 2: Declare requiced _ Variable. =
__ step 3: print“ Fnter_acca element?
Step 4: Read array ee using | for loop
—sbep. Be ibatieed ee oe
Step 6: check if jan then go to Step ay
Step #: initialized j=4- —_ =— =
_ Steps: check if jzd_then_go ko step Qe :
_ Step 4: check if AG1< = aC Uther ee to ep =
pe peeve ee
____iidacjJ= aly pi 2 eT | ee
- ili aL j tie Le ee =
Step LL » prink array_usiag for_ loop: oe
ste 12! ef bop: T % es
progats— a ~
#iadade —————___________ oe
lyoid moain€ Js 2
jotn,@ [tao], 3 1 je bere; ;
printf enter how many elementare there inacryp my,
‘Sank Ci ed , On)
oeintt Enter the values of elements: atin”). oe
‘forC 129; tens itd) ee
7 “cant Und”, Gian : a
“Por Ciz 0; t : eee -
tindede ig eee
lvoid_ main C) ane, ie
tat aCloJLioJ; ECioJCloJ;
ink, ni, 7 - - -
printf (Ener no-of rows Yccluron\n®)-
Sean FU Yad ‘hed ?”, Gen, Gn);
prio“ Enter value of mahix\n™);
for CizO jlems it) ;
NeFor Cjzo , Jone jl 1)
[?
for Ci=O; feo; jet)
Sah Chd ? Gali] GD;
es For Cjr0, jen;
FG IC=aC iI Gj eee eee
pe a - =
Pp. ae pose_oFf Mahix \n??)*
for Ciz0j tem :
5
7 —
er Cj=0; jan jp)
Print Med 1t” EGICI);
[int (8 \n™):
Poo:
output:
| Enter_rowS and_colurans:. 2 3
Enter value of matrix: | 40-5 2%
OAreL Entered mabrix Transpsse_of ratte:
L4 O. = ee |
ch 2 F | 4 9
0 a
Page No,Garite a prograrn. ‘that wil Laccept two- dienensional __
Iquare malri< and find the eur of diagonal —
‘elémenls. CNote- 2furo of _ diagonal _elernents should be —
Caladated for both Sides).
> Algorittsne._ _ - |
Step 1. Sect:
[Skep2: consider has rows and_ Pilenns. |
iSstep? Suro roajore 0
Stee 4: Sum —mainoreO-
istepS:. For( iso: i
Sel aciecl Okccaniae | ee a
Voidenain CQ)
|
int_ne, Factorial. a re as
ink fact Ciat no), mI
clrserC 5
Priot#C* enter a_i aurober
SCanE CE ed. no):
Factorial < Fact (ro)
printf CFactorials ed”, Factorial);
get a
tee ct Cink to).
if Cno==4)
fetucn 4)
else.
“eterno # fack (no -4));
TTT
[Link]) bee
[Enter a_nucobers S$
| factorial = 120
Page No.5) chat iS String? Explain Ou! Shing handling, fonctions
0 detail) corth example: -
= Sbring is iS an array ¢ of char characters
| Syntax: —— —
char array- rome Ciize Jo
example. a es oe
Char Od: - =
iste meen
Ke O123 45 ¢ 2 §q@ |
“Zo” js called aS moll value-It is used_bo. indicate
Lend oF String. a = - :
Sling. fonction : — —
‘Tatclen a ve]
ee to Find eng ith, ok airing ou ut |
Ik iS foduded in “bring. h” header Tile. |
Syntax. Se _ wa.
ink_strlen C8 hing eo _ a |
‘el
| Choe Str l J=" “hello”; ee
int Veo aefdlemGspr i 2 2 ee ae a
“example —
sHintlade zstdio-h>
tHticdod_< Conio-h> — a
Fiodude oo S |
void cocin() - ee |Char str [$0]: st
priottl' Enker_string\n””), BC
gets (sere aes '4
—pzskeint( sh); ——
print CC length of dering = "hd? A), ________
Gul,
fs
Gut pot — . :
Enter a String - Hello-
The. Aengyth o the enkered Striny_is =5
aSercpyl ds a
This sed. fo Copy 6ne_string into another -Tt is__|
indudee!_insbirg bh" header File |
AByokar: - =
i bepyl dtriegt, Bhring 5.)
£4:
Shor 5, ET: hei:
char $.[ lo),
is Shepyl §,, $2);
Findude .
Hirdele
Finude
Void reain( J
|iok 4, :
| Char sr{So] str 2 sop =
pre “Enter String\n"? Ea |
gee lste 1);
age NoSkrepy (dhr2, str 1: ;
PrioHC“ String af ler copy = 15? SH 2
ye ee.
-Ovtepub:-
pape String.
Hello, how are yah:
The new Shrieg ja Helle, how are you &
SyStremeC) function:
ThE foocHon Compares the tvo tring variables passed
bo ib-Tt retorns an. roleger value equal_to
(+01 the two strings are equal. eee!
“Negative value, if “the First Sbring ip. smatter than 2nd
shiteg:
‘positive value, if the First Shing is. greater than te
| S€tond_ Shring
| _— _
exarnple: - _
Hjadede_
# indede
Hinclude Ca, b)?0).
prin CZS. string is greater“ rad,
else a
Pentre: © +708 shring in grea by);
[gh e —_
a
his foncion _Concakenales re kw0 4 String 9 variable passed
fo it. Tk elocns_a. airing of fecoce bhnatic OF the bu in,
thea Ping. variable.
leg: 2H indude
Since _ —_ =
Findude
3 drmaind).
“Chara CO0D, b Cloo J:
[prints Fetes da Slain”) »
gets Ca ):
gets Cb) _
“Streak Ca, bd. OO
PriotfC 7 The Contatenaked soe is* ps? a an
fgetece _
‘Output.
Enter feo. strings: Harsh Rane. oe
Uhe_Concatenafed String 18 __Harsbrane. _
Page No,Date
— - _—_Date:-__
(@6Juncite @ program lo check whelhe the eobered
String is paliddrome or nol- |
S :
Algorithms. : -
Sheet 1: Plart a : |
Step 2: Declare required. “variable = at}
Skep 3* print Enter a. Shring”: ss
Biep4 4'. Read $4. a : a
Slep 5. Copy String skreps (53,5
Eis G. es String Pera Coe
skp 7: “Compare n= Skremp 6). 152),
Step $ ie oo » then. pri palindrome”
“not _patindrore -
Step 4 qe Shop.
ET Pe
Hind de catdio. h>
Hirclude —
void main)
tat n20,i 4
_charalico J, revCloo]:
Lclrser(),
priott C' Enter a. “Strin haa : -
get (a) a =
whileCatayic‘lo)
{oo
bier, = —
_For Cizo; i¢ (n-)5 tee)
Page No.[ie Calijizrev Cid): ee
Lbreak; : |
Lo
|
ie Cizzn). .
print The string 1s palindrome”),
else A :
Printe “The String is nok palindkomne.””),————— -
geo 4 \ . oe
|Date
O7Juurite hort note on Nested aftructure with duitable_
example
TF one_of the members of Ptrudure is also acshudure,
then sucha Strudurc is called ofa nested Structure. |
Sun tax:. = - ae
feud -PHructure- mare
\-dekss- type varioble —name; ces ann
_ Pluck - :
-daka_type - variable..name 5 - . |
Y internal — Prucure — name; |
4 .
|€xarnple:- Q
7 progeam to Prore_the cadius_andien terof acdrcde
ing a_nested Prue,
\# indude
(Struck circle
4
| Float radius »
Strack:
Page No.Float, 9.
qo
| (ee
e :
vOid moain Cy
{
Struct cirde C5 eee
[cleserC 5 tt
prin eae re ee ee ;
[can hCpe, bene”, @ c-radius, Gc-Contre x, Ge centr Hey.)
prinkEC cicde in formahion \n radius = *tF\n centre |
| Co -ordinaker i CAF, 6) C+radiu:
C+ Centre +x, C+ entre +y )
gekebC);,
loukpuk a
LEnter the radius and Cy co-o cdinates_o€ circle: __|
56 +3 :
\Circle_in forenat on.
radius =S+6.
centre co-ordinakes: (2.33: 6
Page No.Date
| float Fees”, -
ee. i pi
void maint) - —
to =
[Struct Student Sy jp.
ClrserC)' _|
Pr intt {Enter the “alladent?s _pame,ColL Pieehers cand
is fees poids? Yiu) st : |
get! 5;,Pame); '
San Cd Hel?) @ S)-rol-00 (s,.Pees);
Lprin bec The student detaHls « are_as_Follows:.\[Link]: hs
lo Rolinembert d\n fees: /-F\0”, 5:-name, —
8; -roll no, $ Bee) — ss
pit: z |
=oukpat- ;
[ectee Pe ePliidenMs name coll nucher 2. fees paid:
Eee kazi 15. Loécoo -
Page Noerie ewe coe eS
+H inJude_
—union_info- EEE
thar Dame C20]; po prey ae |
Jong id _ |
45. - =]
void maint)
onion info it
Int choice;
| Orserd)s,
| printé.c:< enter Your infoccoatien\o = Marne \92-ID_nuraber\!
n_Enter gourchoice:”); |
span ted”, choice)
| witch Choice )
4
[ae pric Henke pos came FY
| Scoink 5? i -
break:
eae
— Sconk C6 dG 5.1 ,
break;
“pha Lb printe (%* Tavalid choice” )-
lif (choices =! )
prin ERC Ky our_name_entered is "hs ismame)
Lelsei ote +22 )-
Page No.printer your Poll nureher ised) 4
pon ,
© — :
Enter Your inforeaticn.____—
Name. pe Oe
DID nerober: 18
_en ker _yoor Gal - —_
vur Marne i5_ darnad Kazi
your Roll Noreber is 15+
roll number),Date
0d Jurite 4 program to read TiHe + Author and Price nam
5 docks using Array of eflruckres- Display the records _
ia ascending order of price :
|
{
|
2Algoritom
[Link]!.
——
4Finvude estdio-h> _
Hindude - .
L## indlude ?
Hindud € éConiozh> is
egret empPloyce. se Sy
—_char came (20; — oe ee
Lek aalary, ae ee et eee
-ghract § eee ee
_
[pe alee nanths gears pe ste
dake — joining — aa a
[eee ee eee
“yoid_rnain C) - — |
Sad ernployce elical. a
eis. ae _
Orsuc jy | _—__« |
(fori 03 1224; depose a il]
iprioteC’ “enter the etmployee’s “parse, Code, salary < and
iE date of joining ad dale, , een Hh 6 year Seperately:"}
Stn en ste dind: ‘Ed thd td” e Cid -name, G dab “OF joining =dake-£
—year-200S Sa aceenenn = —|
“Salory - 80000..___lyear-2005.___
empleyee name = pranav.___lernploy e+ Gaurav.
employee code- 0003 __|salary: |
‘date af joining: 1 oye ‘cede -'Oos. 3
ponth-§ ck joining - 1 ari
ee = 2011. Montb= lo: |
Salary: 10000.. _ ycar=200 _|
Employee. Fist
Alame. code dalary date of joining
Wish. (| 3000 11012006 |
eh | a 25060 0% 12004 |
pranav__| 3 _| 40000 __| Mog i2o1t |
Gaurav 4. 35060 16/101 2007
Page No.OrJurite difference between call by value coll by
reFerence
)p Tn_this case the value of |r Hid case the refesence
the parameker is passed tatheoe the variable is passed bo
}ealled funckion the Fonction by possing the
een eee ere ——ladeeess of th?) fararndters
7To this case the atu! __|o i since the |
-farameters_are oot accessible laddecss of the variable ore _|
thy the called fonction. lquailable. the called function!
ee fan aces the actual |
L. ——|
\SZIhis 1s eoplem kemented_by _|8>7bis is ‘im plemcoted by |
USING Sinap levvatiable naraes.:the_use oF poinker rice
|4z Hence the actual porns
| fernain umdbanged in case oF ican be altered if 7 quired
[the Call by veluc__in case of the cal) by
[examples eit eth "|
Lexarop]e™ &annple
void Swap Ciolx int y.) teed wap Cink * “int *y )
Jot bemp =x Lint temp: * x |
Koy; kus sys
Eemp 5 Ky: beim p- _|
4 IPlt
fat x slo, Mok aslo;
inky =I Link y=;
eer ie before Swap? |prinke¢ values before Suap;
ted ,y=%od \n° "a, y 5 Lwztad, y= elo be
Swap Ggg J) 2 — Suapl dx, Gq):
printt value after Swap; — print CS value af ler sunp :
Eth, Yeh d ay gq), \esthd yee ngs
a3) wate_a- Progran to dp bwo-normbes using Ca)
| by. ceference. ~
= > hlgos acityco'.
Step 4: bart |
Shep 2: Declare required Variable —_ |
skp3- rink Enier -Ewo number".
4. Read a,b ond |
all fonchen, swop Cha, Gb), |
‘skp #:Stop- : /
swap | Gita, wnt *b): i SS eel
Istp 4'-Dedare required variable. - - |
[slep 2: i}ts ta. |
if jid*qr*b |
WiS*b=L-
| siep 3: print_a,b- 7Lprogtaco'.
AW ipdude
Hindede
void 5unpl int 0b.)
void main ©) —
tol x ae ——————_—__—
Pent Enter the value of wand y\n° 2)
Sant Mad “hd 09. by) =
prio © before Swarring \nwee ond \ ny “pd \n”, x xg do
Suwa (Oy, 7 —_——
priokh AE ler Sues \aes tethdlogs td No”, a
gons D5 : = ao —_—
“eid swap int taint th) —
| int ler . — Sa __|
termp =* ua —— ——s |
be ey, - —eeeee |
7a bemp. |
[eae eaies 0f.a_and bis “hed ‘ld \n” a,b).
free te value of by,
Before oS ID
aie wappr of i ——_|
fe —_—
‘valueof AGb is 5 Jo = _ ee __ |
Mf ker 8wapping = a — a
5, yelo: SS