1D Array in C
×


1D Array in C

93

  In C Language, a 1D array can be visualized as a collection of items arranged in a single row, akin to a list.

  Each item is stored in the box called element.

  Box has unique index. you can think of it as a line of numbered boxes where you can put things.

To access an item in the list, you simply specify its index number.

 The numbers inside the boxes represent the elements of the array.

 The numbers below the boxes represent the indices of the array.

 Each box holds an element of the array.

 The array is arranged in a single row.

Example:

#include<stdio.h>
int main()
{
int total[5]= { 80, 90, 70, 60, 50};

printf("The total of first is %d\n", total[0]);
printf("The total of second is %d\n", total[1]);
printf("The total of third is %d\n", total[2]);
printf("The total of fourth is %d\n", total[3]);
printf("The total of fifth is %d\n", total[4]);

return 0;
}
Output:

The total of first is 80
The total of second is 90
The total of third is 70
The total of fourth is 60
The total of fifth is 50
In this code, we declare 1D Array called total to store 5 total elements.



Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments