ANST JavaScript Arithmetic Operations Assignment
Overview
This assignment involves creating a simple JavaScript program that performs basic arithmetic operations on two numbers and prints the results in a clear format.
Task
Write a JavaScript program that does the following:
Declare two variables, num1 and num2, and assign them any two numbers.
Perform the following arithmetic operations and store the results in separate variables:
Addition (+)
Subtraction (-)
Multiplication (*)
Division (/)
Modulus (%)
Print the results in a clear format.
Example Code // Declare two variables and assign them any two numbers let num1 = 20; let num2 = 5;
// Perform arithmetic operations let addition = num1 + num2; let subtraction = num1 - num2; let multiplication = num1 * num2; let division = num1 / num2; let modulus = num1 % num2;
// Print the results console.log("Numbers =", "num1 =", num1, ", num2 =", num2); console.log("Addition =", addition); console.log("Subtraction =", subtraction); console.log("Multiplication =", multiplication); console.log("Division =", division); console.log("Modulus =", modulus);
Expected Output Numbers = num1 = 20 , num2 = 5 Addition = 25 Subtraction = 15 Multiplication = 100 Division = 4 Modulus = 0
How to Run the Program
Copy and paste the code into a JavaScript file (e.g., script.js).
Open a terminal or command prompt.
Navigate to the directory where the file is located.
Run the script using Node.js: node script.js
How to Push to GitHub
Ensure Git is installed on your system.
Navigate to your project directory in the terminal.
Run the following commands: git add . git commit -m "Added JavaScript arithmetic operations program" git push origin main