Users Online

· Guests Online: 138

· Members Online: 0

· Total Members: 188
· Newest Member: meenachowdary055

Forum Threads

Newest Threads
No Threads created
Hottest Threads
No Threads created

Latest Articles

C# Program to Find the Length of Jagged Array using Predefined Functions

C# Program to Find the Length of Jagged Array using Predefined Functions

 

 

 

This is a C# Program to find the length of the jagged array using predefined functions.

Problem Description

This C# Program Finds the Length of the Jagged Array using Predefined Functions.

Problem Solution

Here the Length of each row in the jagged array is calculated and displayed.

Program/Source Code

Here is source code of the C# Program to Find the Length of the Jagged Array using Predefined Functions. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

/*
 * C# Program to Find the Length of the Jagged Array using Predefined Functions
 */
using System;
class Program
{
    public static void Main()
    {
        byte[][] numbers = new byte[5][];
        for (int i = 0; i < numbers.Length; i++)
        {
            numbers[i] = new byte[i + 3];
        }
        for (int i = 0; i < numbers.Length; i++)
        {
            Console.WriteLine("Length of row {0} is {1}", i, numbers[i].Length);
        }
        Console.Read();
    }
}
Program Explanation

This C# program is used to find the length of the jagged array using predefined functions. A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes.

 

A jagged array is sometimes called an “array of arrays.” The following examples show how to declare, initialize, and access jagged arrays. For loop is used to assign an element value starting with 3 for an array. Hence another for loop is used to print the elements of an array.

Runtime Test Cases
 
Length of row 0 is 3
Length of row 1 is 4
Length of row 2 is 5
Length of row 3 is 6
Length of row 4 is 7

 

Comments

No Comments have been Posted.

Post Comment

Please Login to Post a Comment.

Ratings

Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Render time: 2.16 seconds
10,853,682 unique visits