Sunday, February 25, 2018

What is the output of the following program?

Soln:
Suruma n=2 ra c=1 xa
Ani while c<=10 bhaneko c chai 10 wa 10 bhanda kam huda samma loop bhairahanxa. Bhanepaxi looping sakkina c=11 hunuparxa.
Suruma "Print n" bhanya xa tesaile 2 print hunxa............(i)

tespaxi, n=n+c xa bhanepaxi n=2+1=3 hunebhayo
c=c+1 xa tesaile c=1+1=2 hune bhayo

(c=2) chai 11 bhanda kam xa tesaile feri looping hunxa
Wend le feri while ma pathauxa;
Ani print n xa bhanepaxi agi n=3 bhako thiyo tesaile second looping ma 3 print hunxa.....................(ii)
feri n=n+c xa, n=3+2=5 hunxa 
c=c+1 xa c=2+1=3 hunxa

(c=3) feri 11 bhanda kam bhayera feri looping hunxa
mathi n=5 bhako thiyo tesaile 5 print hunxa................(iii)
n=5+3=8 hunxa
c=3+1=4 hunxa

c feri 11 bhanda kam xa, feri looping hunxa
ani n=8 bhayekale 8 print hunxa...............(iv)
n=8+c=8+4=12 hunxa
c=c+1=4+1=5

c=5 xa ra yo feri while ma bhako condition satisfy garxa
yesari c=5 huda kheri 12 print hunxa...........(v)
c=6 huda kheri 17 print hunxa...........(vi)
c=7 huda kheri 23 print hunxa...........(vii)
c=8 huda kheri 30 print hunxa...........(viii)
c=9 huda kheri 38 print hunxa...........(ix)
c=10 ko condition pani satisfy hunxa ra 47 print hunxa........(x)
Aba c=c+1 bhayera c=11 hunxa ra condition satisfy gardaina ra looping stop hunxa
Ani output chai
2
3
5
8
12
17
23
30
38
47