Physics, asked by biswasprapti18, 6 months ago

write a javascript program to print all odd numbers between 100 to 140
plz solve this. ​

Answers

Answered by AryanSut
0
100 to 400...................
Answered by mad210202
0

Answer:

The javascript program to print all odd number between 100-140.

Explanation:

By using function:

function print(){  

var i;  

var write = document.getElementsByTagName('h1')[0];  

for(i = 100; i <= 140; i++){  

  if((i % 2) == 0){  

   continue; //if num is odd, skip it.  

  }  

 write.innerHTML += i + '<br/>';  

}  

}  

print(); //invoke print function

Alternate code -

alert("Welcome to javascript :D");

document.write("Odd numbers from 100 to 140:");

for(var i=100;i<=140;i++)

{

if((i%2)!=0){

document.write(i +"<br/>")

}

}

Similar questions