
#SORTING AN ARRAY IN COBOL PROGRAM HOW TO#
This is a demo program to learn and understand the concept of subscript property of an array and how to assign values to array. Here in this program, we have assigned a few variables with different values and later manipulated the output using different properties of an array to make you clear about the different concepts related to INDEX BY property of an ARRAY. MOVE WS - ITEM - VAL TO WS - ITEM - CODE(IDX).ĭISPLAY " PRODUCT " WS - ITEM - CODE(IDX). Ġ5 WS - PRODUCT OCCURS 3 TIMES INDEXED BY IDX. This is a demo program to learn and understand the concept of index by property of an array and how to assign values to array. With this program and output, you will be able to understand how convenient and easy multi-dimensional arrays are. Here in this program, we have assigned a few variables with different values and later manipulated the output using different properties of an array to make you clear about the different concepts related to TWO-DIMENSIONAL ARRAY. THE OUTPUT WILL BE I AM EXAMPLE OF TWO DIMENSIONAL ARRAY PERFORM PRODUCT-PARA VARYING I FROM 1 BY 1 UNTIL I > 3 CREATING 2 DIMENSIONAL ARRAYĭISPLAY "I AM EXAMPLE OF TWO DIMENSIONAL ARRAY".

This is a demo program to learn and understand the concept of two-dimensional array and how to assign values to array. With this program and output, you will be able to understand how convenient and easy arrays are. Here in this program, we have assigned a few variables with different values and later manipulated the output using different properties of an array to make you clear about the different concepts related to ONE DIMENSIONAL ARRAY. THE OUTPUT WILL BE I AM EXAMPLE OF ONE DIMENSIONAL ARRAY CREATING 1 DIMENSIONAL ARRAYĭISPLAY "I AM EXAMPLE OF ONE DIMENSIONAL ARRAY". This is a demo program to learn and understand the concept of one-dimensional array and how to assign values to array.

In order to select element two in the last example, we have to do the following To refer an element one in the last example, we have to give NAME-DAY(1)

There are two ways to refer to the elements in an array:

Instead of defining the same type of data multiple times that may fall under the same category or group, COBOL provides us with a powerful function called as array.
