C# Program to Find the Length of an Array1 min read

In this tutorial, we will write a C# program to find the length of an array entered by the user, we have used while loop and trycatch block for the exception

Question:
Write a C# program to find the length of an Array.

Solution:
Here first we take the arrays from the user and to exit from an array user need to enter –999 at last. -999 is an exit value that is defined at the beginning of the program.

To take the user input, while loop is used inside which try-and catch blocks are executed. lastly array.Length is used to get how many elements the user entered.


C# Program to find the length of an Array.

It can also be done without the use of try-catch block

Source Code

Output:


MORE

Find the output ab, cd, ef, g for the input a,b,c,d,e,f,g in Javascript and Python

In this tutorial, we will write a program to find a pairs of elements from an array such that for the input [a,b,c,d,e,f,g] we will …
Read More

String Pattern Programs in C

In this tutorial, we will write various C pattern programs for String. Before that, you may go through the following topics in C. for loop …
Read More

Java Program to Find pair of Integers in Array whose sum is given Number

In this tutorial, we will write a program to find a pair of elements from an array whose sum equals a given number in java …
Read More

Program to Print Diamond Alphabet Patterns in C

In this tutorial, we will learn to write a C program to print Diamond patterns using alphabets/characters. However, in this tutorial, we will create a …
Read More

Half Diamond Pattern in C using Alphabets

In this tutorial, we will learn and code the half diamond alphabet patterns in C programming language. However, in this tutorial, we will create a …
Read More

Half Pyramid of Alphabets in C

In this tutorial, we will learn and code alphabet patterns in C programming language specifically the Half pyramid of alphabets in C programming. However, in …
Read More