Macadangdang Ipt Activity1
Macadangdang Ipt Activity1
Asingan, Pangasinan
ACTIVITY 1
CODE: HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Diagonal Sum Calculator</title>
<style>
.highlight {
color: red;
}
</style>
</head>
<body>
<h1>Diagonal Sum Calculator</h1>
<label for="arrayInput">Enter the two-dimensional array (comma separated):</label>
<br>
<textarea id="arrayInput" rows="5" cols="50"></textarea>
<br>
<button onclick="calculateDiagonalSum()">Calculate Diagonal Sum</button>
<br>
<p id="result"></p>
<script>
function calculateDiagonalSum() {
const arrayInput = document.getElementById('arrayInput').value;
const arrayRows = arrayInput.trim().split('\n');
const array = [];
function calculateDiagonalSumFromJS(array) {
let sum = 0;
const size = Math.min(array.length, array[0].length);
return sum;
}
</script>
</body>
</html>
C#
using System;
class program
{
static void Main()
{
int[,] array = {
{ 22, 50, 11, 2, 49 },
{ 92, 63, 12, 64, 37 },
{ 75, 23, 64, 12, 99 },
{ 21, 25, 71, 69, 39 },
{ 19, 39, 58, 28, 83 }
};
return sum;
}
}
<script>
function processArray() {
const arrayInput = document.getElementById('arrayInput').value;
const array = arrayInput.split(',').map(Number);
document.getElementById('negativeElements').innerText =
'Negative elements: ' + (negativeElements.length > 0 ? negativeElements.join(', ') : 'None');
document.getElementById('sumOfNegatives').innerText =
'Sum of negative elements: ' + sumOfNegatives;
}
</script>
</body>
</html>
C#
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System;
using System.Collections.Generic;
using System.Linq;
return Page();
}
}
<script>
function calculateMaxMinSum() {
const arrayInput = document.getElementById('arrayInput').value;
const array = arrayInput.split(',').map(Number);
if (array.length === 0) {
document.getElementById('result').innerText = 'Please enter some elements.';
return;
}
C#
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System;
using System.Linq;
if (array.Length == 0)
{
ResultMessage = "No elements found in the array.";
return Page();
}
return Page();
}
}
CODE: HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Array Manipulation</title>
</head>
<body>
<h1>Array Manipulation</h1>
<p id="output"></p>
<label for="positionInsert">Enter the position where you want to insert a new element:</label>
<input type="number" id="positionInsert">
<label for="elementInsert">Enter the element to insert:</label>
<input type="number" id="elementInsert">
<button onclick="insertElement()">Insert</button>
<label for="positionDelete">Enter the position from where you want to delete an element:</label>
<input type="number" id="positionDelete">
<button onclick="deleteElement()">Delete</button>
<script>
let array = [1, 2, 3, 4, 5];
function printArray() {
document.getElementById("output").innerText = "Array: " + array.join(" ");
}
function insertElement() {
let position = parseInt(document.getElementById("positionInsert").value);
let element = parseInt(document.getElementById("elementInsert").value);
function deleteElement() {
let position = parseInt(document.getElementById("positionDelete").value);
if (isNaN(position)) {
alert("Please enter a valid position.");
return;
}
if (position < 0 || position >= array.length) {
alert("Position is out of range.");
return;
}
array.splice(position, 1);
printArray();
}
printArray();
</script>
</body>
</html>
C#
using System;
Console.WriteLine("Original Array:");
PrintArray(array);
CODE: HTML
<!DOCTYPE html>
<html>
<head>
<title>Fourth Largest Element</title>
</head>
<body>
<h1>Fourth Largest Element</h1>
<p>The fourth largest element in the array is:</p>
</body>
</html>
C#
using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace YourNamespace.Pages
{
public class FourthLargestModel : PageModel
{
public int FourthLargest { get; set; }
FourthLargest = FindFourthLargest(array);
}
Array.Sort(arr);