To write a C# program to create a sample CPU usage on a network with 4 nodes using a jagged array.
Create a new Class named cpu.
Create a jagged array of 4 arrays.
int[][] array = new int[][];
Create as many sub-nodes as you wish inside one node of jagged array.
Give the sample CPU usage in the jagged array.
Print the sample CPU usage in the jagged array.
End the Program.
Developed By: Gunaseelan G
Register No: 212221230031
using System;
namespace jaggedarray
{
class Program
{
static void Main(string[] args)
{
int[][] cpu = new int[4][];
cpu[0] = new int[3];
cpu[1] = new int[4];
cpu[2] = new int[5];
cpu[3] = new int[2];
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 < 4; i++)
{
for (int j = 0; j < cpu[i].Length; j++)
{
Console.WriteLine("Cpu usage of node " + i + " is " + 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.