Display number sequence from 100 to 150 and display in following format example 100 101 102 ..150

 

Display number sequence from 100 to 150 in following format.(100 101 102 ....150).


Example 1.Using for loop

<!DOCTYPE html>

<html>

<head>

<title>Sequence Program</title>

</head>

<body>

<script type="text/javascript">

var i;

document.write("Javascript program for sequence 101 102..150"+"<br>");

for(i=100;i<=150;i++)

{

document.write(i+"  ");

}

</script>

</body>

</html>

Output-

Program for sequence 101 102..150
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150

Example 2.Using while loop

<!DOCTYPE html>

<html>

<head>

<title>Sequence Program</title>

</head>

<body>

<script type="text/javascript">

var i;

document.write("Program for sequence 101 102..150"+"<br>");

i=100;

while(i<=150)

{

document.write(i+"  ");

i++;

}

</script></body>

</html>


Output-

Program for sequence 101 102..150
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150





Previous
Next Post »

Please Comment and Share. ConversionConversion EmoticonEmoticon