Q1. Draw Flowchart For Following:: Read N

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 10

Q1.

Draw flowchart for following:

n
1.

a
i=1

Read n sum=0

i:=1 to n step 1
sum=sum+i

Print sum

Q2. Compute average of n numbers

Read n total=0, avg=0

i:=1 to n step 1
Read num

total=total+num

Avg=total/n Print avg

n Q3. H= n/(1/ai) i=1

Read n sum=0

for i:=1 to n step 1


sum=sum+i

H=n/sum Print H

Q4. s=1+2+3+..+n

Read n s=0

for i:=1 to n step 1


s=s+i

Print s

Q5. s=1+3+5+.+n

Read n s=0

for i:=1 to n step 2


s=s+i

Print s

Q6 s=2+4+6++n

Read n s=0

for i:=2 to n step 2


s=s+i

Print s

Q7 s=1+1/2+1/3+1/4+.+1/n

Read n s=1

i:=2 to n step 1
s=s+(1/i)

Print s

Q8 Generate the sequence 1 2 4 8 16 32

Read n s=1 Print s

i:=1 to n-1 step 1


s=s*2 Print s

9. Generate the above sequence without using multiplication.

Read n s=1 Print s

i:=1 to n-1 step 1


s=s+s Print s

10. Find the second maximum from given array.

Int I, J, T

For I:=(n-2) to 0, step 1

For J:=0 to I, step 1


FALSE TRUE

a[j If ]> a [j ] +1

TRUE

T=a[J] a[J]=a[J+1] a[J+1]=T

Print a[1]

10

You might also like