Docsity

Programming Flow, If-Else & Loops, Study notes of Computer science

Partial preview of the text

Download Programming Flow, If-Else & Loops and more Study notes Computer science in PDF only on Docsity!

1 (f Sum of two numbers -___ ZScript > vay x= (0; var y = 20: Var z= xty, document write (2); Liscript 7 Output : 30 | Lrarea of rectangle ZScript > Uard = (0 ; var 6 = 20: ‘var a7 L* 0: document write (a): Liscript 7 Output: 2-11 Simple fteret csuript > Udr p= (0000 ; var t-=2, vor ¥795, vor i= (pet *y)/100- document: wrrte cr) ' Z lscript > wy _1/_1f condition cocript > vor a= 20: if (a7 -'&) f document: write C "yalid € 3 L [script 7 | or vote”); ¢: [tif --- elre condition for vole Zocript > vor a=0; ff (ar=1e) vy Clocument - Write C“valid for vate')- J el ¢@ ui . 5 document: write C"invalid for vote). j Ll ccript 7 TLILPE Clee rf Condition a Zccrpt > var Q= 20; TF (a== 10) My Caument -crrte ("a i¢ equal to 10"); y ee (Ff (a= 215) Ny clocument- write ("a ¢ equal to 15"): Clee if (a= =90) f domment: write Cra ic equal to 20") ; 4 else | document: write (a ic not equal to 10,15 or 20°)- Li script > JF /t_ the Otro if_condition_fo1_tmailest among three nop. Let pt s var a= 10: ivar 6 = 20. | 4 \Uar ¢ = 30 - f (acb ee bcc) ie | Clocument - curite "a re emailer”) - 3 ‘ else vf (620 &e bcC) v document: write "6 44 cmaitert "): / else N document: corrte C''¢ ry (arge(t)- 3 rd CLcripr? - 0: f1 switch core for da —— c script ? var doy 26: Valtch (day ) M case 1: document - write (sunday "). break ; . case 2: document. write ¢ "Monday ")- break ; ° cOle 3: document -crite (" Tuesday ase: , document. write (" Wednesday); break ; \case S : document - write C" Thursday) ; break: case g document. write * Friday"): break ; Kale F? document -arite ( "¢aturday a: break; default document: witte ("invalid day "J: j Liscript 7 | | | | ff 1 0.9 using for loop. ii eoec Lacript > vor i; for (P=4; 1255; x ° ° (document write Cit “2bri>") 4 ‘L/script > | | | itt) | | | I create sorter Itke 43549 Uting for ap Locript > var i for Ci: 1, 2-10; fs it 2) f document: write Cit "br/>") 9 Z 1 script ) (Fcreate ceies KE 2 46 8 10 ting for 100p écript 7 var f: for cis 2) fe +40) Fe ir 2) Ny document: corite ci¢ "COr/>" ) 9 Cisatpt > (natural number Up to 10 Wing for top Zccript > var I for (iz £; 1210; it t) Ne document: wante Cit "Cor />") 3 Ciscript 7 (15 fos using for (00p ° script > var t | for (i=5; f> =4:7--) J document -write Cit "Lor/z") J Z (script > ff 4 to 5 using While loop Lécript > vari= 4, While CiL=5) Neocron: corite Cit "COK/ >) PFT ; g Z/ccript > _ Mt 5 times. your name using while loop Cscript> var 1 =4- while (°2 75) f document -crite C"timran"+ "Zor (>; CPt: J Z (script > St 5 tot using while loop ee script > Wor f=5; whfle ci >=4) v 4 wy. ‘document. write cit “eb /2 D5 f--; 9 Z lscript 7