Write a program in javascript, that take numbers from 1….20 in an array. Separate Even and Odd numbers by using conditional statement. Figure # 01 is the output of this file on web browser.
Example:
Odd Number = 1
Even Number = 2
Odd Number = 3
Even Number = 4
Odd Number = 5
Even Number = 6
Odd Number = 7
Even Number = 8
Odd Number = 9
Even Number = 10
Odd Number = 11
Even Number = 12
Odd Number = 13
Even Number = 14
Odd Number = 15
Even Number = 16
Odd Number = 17
Even Number = 18
Odd Number = 19
Even Number = 20
A program in javascript, that takes numbers from 1….20 in an array and print the even and odd number:
<!DOCTYPE html>
<html>
<body>
<script>
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20];
numbers.forEach(oddEvenFunction);
function oddEvenFunction(value, index, array)
{
if ((value % 2) == 0)
document.writeln("Even Number = " + value +
'<br/>');
else
document.writeln("Odd Number = " + value +
'<br/>');
}
</script>
</body>
</html>
OUTPUT:
Odd Number = 1
Even Number = 2
Odd Number = 3
Even Number = 4
Odd Number = 5
Even Number = 6
Odd Number = 7
Even Number = 8
Odd Number = 9
Even Number = 10
Odd Number = 11
Even Number = 12
Odd Number = 13
Even Number = 14
Odd Number = 15
Even Number = 16
Odd Number = 17
Even Number = 18
Odd Number = 19
Even Number = 20
Write a program in javascript, that take numbers from 1….20 in an array. Separate Even and...
<!DOCTYPE HTML>
<html lang="en">
<title>JavaScript Array Lab</title>
<script src="script.js"></script>
<body>
<p>To test your function,
call divideArray()
from the JavaScript console in the browser.</p>
</body>
</html>
Don't edit your code on the above code and do not copy from
others', plz!
// Put your solution here in script.js
Write the function divideArray() in script.js that has a single numbers parameter containing an array of integers. The function should divide numbers into two arrays, evenNums for...
Write a program in JavaScript, that take (07) days temperatures from user and display the temperature in centigrade, Fahrenheit and kelvin on web browser. Hint: you can use array, for loop .
Problem: Write a program that generates random numbers between 1 and 10 and fill an array of size 20 with them. Have your program sort the array then output in order the number of occurrences of each random number generated. Use the STL sort function to sort your array. How to use the STL sort: #include <algorithm> ... int a[20] ... sort(a,a+20); Example Output: This program generates random numbers and tabulates the results Original List Sorted: a[ 0] 1 a[...
Write a program that check odd / even numbers (from number 1 to
100). Display the results within an HTML table with 2 columns: one
for odd number and one for even numbers.
NUMBERS RESULTS ODD EVEN ODD 2 HINT: use <table> tags to create a table, <th> tags for 'Numbers' and 'Results'. Wrap code PHP inside HTML code. For example: <html> <title>CHECK ODD or EVEN</title> <body> <table> ?php echo "<tr><td>l</td><td>Odd</td</tr>"; </table> </body </html 2. Do the following steps in...
Write a c# program in Microsoft visual studio to determine if the following numbers are even or not. Create an app that will read integers from an input file name Number.txt that will consist of one integer. Determine which numbers are even and which are odd. Write the even numbers to a file named Even.txt and the odd numbers to a file named Odd.txt. Number.txt 20 39 45 12 31 62 10 11 21 73 14 42 55 86 109...
Javascript: Create a loop that counts from 1 to 20. // If the current number is even, add it to this empty array: var myArray = []; // If the current number is odd, log an odd number warning to // the console. // However, if the number equals 19, set a debug breakpoint. // After the loop completes, print the array to the console.
Write a program that reads in two hexadecimal numbers from a file, hex.dat, and prints out the sum of the two numbers in hexadecimal. (As noted in class, first do this without using a file and by reading using the cin > > command) From Wikipedia: "In mathematics and computer science, hexadecimal (also base 16, or hex) is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0-9 to...
Python Help Create a program that outputs a table from 1 to 5 using what you've learned about "for" loops. Your program will print the number and indicate if the number is odd or even. If it is not odd you will multiply 2 numbers with it: number 1 and number 2. Your program must do the multiplication for only even numbers in the table. The output of your program should look like the figure below. Hint: Create a program...
Program Requirements First, find all the prime numbers between 2 and a user-inputted number from the console (inclusive). The identified prime numbers must be stored in an array . The inputted number should be between 0 and 1000 (inclusive). array is large enough to o Make sure your hold all the prim e numbers. Dynamic memory allocation is not required for this assignment, so you can have unused space in your array Make sure you can handle the cases of...
PLEASE SOLVE USING BASIC C++ CODEING PRINCIPLES
PLEASE USE BASIC ARRAY, FUNCTION, AND LOOPING PRINCIPLES
PLEASE COMPLETE ALL ASPECTS OF PAPER
THANK YOU!!!
Objectives To learn to code, compile and run a program containing ARRAYS. . Assignment Plan and code a modular program utilizing arrays. Use at least three functions to solve the problem. Input numbers from a textfile. Input the numbers, one by one. Store the even numbers in one array. Store the odd numbers in a second array....