In this exercise, you will write a while statement that displays all odd numbers
ID: 2246280 • Letter: I
Question
In this exercise, you will write a while statement that displays all odd numbers between 1 and
100 on the screen. Complete the steps below:
1. Open Notepad++ and create a new document.
2. Type the <!DOCTYPE> declaration, <html> element, header information, and <body>
element. Use the strict DTD and “Odd Numbers” as the content of the <title>
element.
3. Create a script section in the document body with a while statement that displays all
odd numbers between 1 and 100 on the screen.
4. Save the document as OddNumbersLastname.php (Lastname should be your last name)
in the Projects directory of your student data files. Open it in your Web browser to see
how it renders.
5. Finally, upload the file to the assignment dropbox in Blackboard.
This is what I have done so far-I know it's not much.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Odd Numbers</title>
</head>
<body>
</body>
</html>
Explanation / Answer
<!DOCTYPE html>
<html>
<head>
<title>Odd numbers</title>
<script language="javascript">
var a,odd=0;
document.write("The odd numbers between 1 to 100");
for(a=0;a<100;a++)
{
if(a%2!=0)
{
document.write("<br/>"+a);
odd++;
}
}
</script>
</head>
<body>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.