0% found this document useful (0 votes)
21 views

PPS 5th Assignment With Qna

Uploaded by

kanailalm861
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

PPS 5th Assignment With Qna

Uploaded by

kanailalm861
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

9) Deelane aglay o 10 elenant

assign values
inikalise tae vaue at combile time ond
duplay tem.
OFlouchant Pom keyboad ,disolay hem.

Start

Tnihaise cn anna a with values


3,2,3,4,5, b,*,8, 9;0 (at
Print ekore the nhalisahiny
te vaues are.

No

Yes

Print ai].

Print Noo ente the


values:

No

Yes
a); 2 printf("
:\n ane vales he
sahn iniiai the Before þrintf
HAUSEH
bionix
o},i; 5,69,
,ioj-,24,
3,3, aint
mainl)
#include<stdio.h7
Crogram ;
Stop
I:^i+1
aT] Print
Yes
No
i:=0
vas the
inihallizah
on au: Aten Pri"nt
i:=i+1
ati]
nte Read
00 90 89 I8 64 56 45 34 23 12
valuen tue ationinihas ter Af
5C
45
34
23
vaes: 12
te enter Noo
3 2 1
are. value the the Before
OOutput:
3
values heaom all.s inih Affen print
scal%2
ai) 3
vaes the entor Nqþrint\
o
3
Find the average mmbo wing aray
Flawchant
Stant

Punt Bynten thoae double


elementy:"

No
is2
yes

Reud ad store
Vaue for a ]

i:si+1

No
2
Yes
Sum :SAM+ af1

avg:= sum 3

Print The average value

stop
cProgt
#incdud stdio.h
main()

int i
loud sum=0.0, als!, avg
þrint (" Enter hne doable denents:n");
orl i-0;i(*2; iv)

3
for(is0, i(=2; i+ +)
Sum Sum t

avg =sum/3
value n o-2 avg)
3
utpu
Enten Hree doube elements :
12-34
5618
89'DI
Ten avetage value 52:11
2Find the avouse humbey of J0 inbagers uing anay'

Stant

Print ^Enten 10
integen elenents

No
Yes
Read and store vaeo
aCi]

ik=i+1

No

Yes

Sum:sum +a

i:zi+1

avg= Sum

Rrinthe aveage value avg

Siof
*indude (stlio.h)
maàn( )
int o],i
float suna 0.0, avgs
rint( Enlen 10 integeu dhmutsn);
for (i=0, ikoi)

3
Aorizo, i(=9;itt)
Suma Sumt
um+ aiJ;

arg= Jum/10,
prir Te average value n
.02 avg):
Output
Enten 10 integer elements:
12.
23
34
45
56
89

123
33
The avnage value in 57-20.
4 Find min demert witin a Wst of 4 elaments

Sant

/PrintEnterz dements
i:z0
No
Yes
Read nd stere value
at aM

i:zit1

min:z aLo1
it=0
NY
Yes
mina

Print The minimun vabe is


min V.

Stop
main()
int a min,
print Enton 1 integez
dements:

3
min

3
printt(" e inimun value in
3
Ente 1 nte
integen elements:
-1
23
4

Vaue n -69.
5) Find maz elemont within oa int of element:

Step1- Stant
Stek 2: Enten t integer elmentsi Print.

Stuk4: Frr isb


Stele 41: Read and store vaue at
ai].
Stee 42: si+
Step 5: End f Loop
Sheb &: ma i ao]
Steb: i:z0
ShepB: for is6
Step 8-1: Je mas aiT
Sheb 81: maz:= a]
Step 8-2: : 1
Step 9: End of Looe
Step D Printhe mazimum yalue n max

Step
#inclade stdio.h)
mun()

al;
or ( iso, i (=bi+t)

maZ a l ;

pri ntf( The mazimum value in W.d maz)


3
Erter 7integer eements:.
2

-12
4
5
23
The manimum voue n 78.
9 Consract Rrom binany to
decimd Jot101 a 45
Step i: Stat
Shep2 Inih de nmay a
with 1,0. 31, 0,1 (at
Stejp 3: is0
Stelp 4: j:-0
Steb5: For i75
Stufp 54: deo := deci+ (aiJx 2')
Step 5:2 =jti
Step 5:3: i:ai+1
Shelp & End ot Looe
Stek t. Print The deimad value is de

#incdade (stoi o. h)
include <math h
main()

int o o- 1,0,1,1, D,13, deci =c0,, j=0,


rli-o, i<5, i*t)
þrint(The decimal vabue u 2.3" de ci),
OOutput
Tre deomal value n
45.
Tnsent element in asoeitie bosihon ot an
Algorihm :
Step 1: Stant
Shep 2. PrintEnten you
elements:
Step 3: i:=d
Sheb 4 For is4
Ste74: Read and store he alae of a1
aD].
Shek 42: i:=1
Steb 5: End ot Lop
Step ' Print Enten the vaue you wart to insent :
Stek 3: Resd val Vanj able

Step 8: Print "Ent the basifion you Coant to insezt


1/
val:
for i:0,i=4, itt)

printf(" Enten te vale yau ant to inezt)

prinh("Enter Hhe posiioa you want to


insent: ")

a[inil- a1;

a[i-] vad ;
print Aften the inserhon the values
vabues ane:n
torl i=0, i<=4;it)

3
Enten ylun elemens.
2
3
4
5
Enten tue value yo
want to insent: 420
Enten the poshon yo wnt to insent 420
3
AFtee he insech on e
1
values e:
4 20 3 45

bement Grom
O Algorithm; sheuife hakon:
Steb 1: Stant
Step 2: Privt Enter yow elementy:"
Step 3? i:=0
Shep 4: For is5
Steb 41: Read amd shre te vale ot a7
Step 42: i:=h+1
Shep 5: End o Loob
Steb &: Prirt" Enter ne ihon you want to
delete :

Step: Read tueivaniabe.


Shep 8: va. := ai-J
Stelp9: i: /-1
i<5

Steb s0-2: j:=it1


Steo 13: End ot Loop
Stek 12: Print" After val
ddeing Hhe values ae:

Stelo 13: i:=0


Step 14: For i74
Stee 141: Print a[I.
Skep 142: i:zitt
Shelp (5: Stoe.
C Prog am :
#induck <ctie. h
mainl)

int a6], ad, i, j;


printf(" Ente you dements:
Rorl ino, i <-5; it)
Steps0: i:s4

Stak 33.4: a[i+i:=a]


Shep 392: a]:=0
Shep 14:3: isi-s
Step 12: End of loop
Step 13: ali-]:s val
Step 14 Print "Aften
tue 'nsenhon the valuey
Step 15: i#=D
Step 16: For is4
Stelp lb-1. Print aD].
Stek 1b2: iieit1
Stelp la: End of Loob

#indude <stio.h
main l)

int a], al, i, i;


print{(Enten you element :n ")
print(^Erton the boithon you wwant to dekte:

Val= ai-,
for (izo,is=5;i+5)

plntt" Af te deleing d the values are

þrint(7.a a0);
3

Enher yn elements:
l2
22

45
54

Ente the posi tin you ount to deete 4


doehng 45 te
Aten deehng vaues
12 23 34 56
Programming for Problem Solving (ES-CS291)
Questionnaire:
1. Explain the difference between break and continue.
2. What will happen if a break statement is
an example.
encountered within a nested loop? Explain with
3. Explain with an example how the value of the
loop variable of an outer loop may control
the number of iterations of an inner loop. Can the value of the loop variable of an inner
loop control the number of iterations of an outer loop?
.Tve break statement eit
the Loop or s wteh
Control do the
nert statemen anstruct entirey transkering
owside tue lop /saiteh. In
statement sips te nemaining code in te eontrest,
ond moves to tve went
next iteabon ,aloiny te loop to
Contine.
2- 1e a break statenen encounted witin a ruted ob, it
aill terminate the inne
lop in ahch ih
bresent,but not
Eranpe.

breuk;
Teacher's signature with date :
3

Inen loob 2 e inhen looo,Hee break habonord


Outen loop: 2 tomi naing tae innen
lole. lHowONen, hue uken loole
Janes loop: 2 ntirue
Cuten lo 3 eaeukng , prining tae femairing
iterai ons.
Jhnen lop : 2
3. The lo vasuabe of an outer contrd fne
numbe of itenaio n innen lopp ky wing it
the inne in
loabs condi hon. Fer eampe,

Tn tais enamde, te Juns me or each


outer loo, prinbhg i asteisks Houeen
an inne vaiable Cannot irchly
of an owter lop.

You might also like