C Language Video

Back - C Language Notes By Vivek Sir email: vivekdubey22@gmail.com (w) 9826424484

What is the purpose of an array in C programming? Write Advantages and Disadvantages of an Array.

·        In C programming array is a derived data type.

·        Main purpose of array in C programming language is to store multiple values of same data type.

Explanation:

·        int i=0; char ch=’a’;

in above example variable i can store only one value of only integer type.

As well as variable ch can also store only one alphanumeric value.

But in array if we declare array as a integer then n number can be stored of integer type of value where n is index of array

·        int arr[n];

·        int arr[10];

·        char ch[10];

in above example we can store 10 integer values in arr variable as well as 10 character string in ch variable.

Advantages of an array:

·        Multiple values can be stored of same data type.

·        Searching, sorting, insert, delete operations can be performed on array.

Disadvantages of an array:

·        Ones, an array is declared as a integer then only values of integer type only can store rather character or float type.

·        More than array limit, values cannot able store in array, for example if arr[10] is declared then beyond limit  of array i.e. 10, can’t store values.

 

C Language Video

Back - C Language Notes By Vivek Sir email: vivekdubey22@gmail.com (w) 9826424484