DO WHILE LOOP / FOR LOOP / HOW TO USE N NUMBER OF LOOPS
DO WHILE LOOP:-
in this loop is also called exist loop because in this loop first execute the statement than check the condition.
<html>
<head>
<script language="JavaScript">
var i=1;
do
{
document.write(i);
i=i+1;
}
while(i<=10);
</script>
</head>
</html>
FOR LOOP:-
-while and do while loop is required multiple line.
-we have to use and other type of loops is called for loop, it is also called single line loop.
-for loop is dividing into 3 sections.
1)variable loop
2)condition loop
3)increment or decrement
<html>
<head>
<script language="JavaScript">
var i;
for(i=1; i<=10; i=i+1)
{
document.write(i);
}
</script>
</head>
</html>
HOW TO USE N NUMBER OF LOOPS:-
(N= user input)
<html>
<head>
<script language="JavaScript">
var i=1,N;
N=parseInt(prompt("enter any number"));
for(i=1; i<=N; i=i+1)
{
document.write(i);
}
</script>
</head>
</html>
TASK 1:-
-convert all looping concept into N number of program.
(10 ki jagah N)
Comments
Post a Comment