To write a C# program to create a sample CPU usage on a network with 4 nodes using a jagged array.
Start the program.
Create a jagged array of 4arrays.
Give the sample CPU usage in the jagged array.
Print the sample CPU usage in the jagged array.
End the program.
Developed by : Gayathri A
Register Number : 212221230028
using System;
namespace jagged_array
{
class Program
{
static void Main(string[] args)
{
int[][] cpu = new int[4][];
{
cpu[0] = new int[3];
cpu[1] = new int[2];
cpu[2] = new int[2];
cpu[3] = new int[4];
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < cpu[i].Length; j++)
{
cpu[i][j] = i * j + 70;
}
}
for (int i = 0; i < cpu.Length; i++)
{
for (int j = 0; j < cpu[i].Length; j++)
{
Console.WriteLine("CPU usage at node {0} is {1}", i, cpu[i][j]);
}
Console.WriteLine();
}
}
}
}
}
Thus,C# program to create a sample CPU usage on a network with 4 nodes using a jagged array is executed successfully.