Home Array
Post
Cancel

Array

An array in C++ is like a sequence of variables.Arrays have 0 based indexing which means the first element is stored in 0th place and last at size-1th place.array_name[index] gives the element at that place(index).

1
2
3
4
5
6
7
8
9
10
11
12
13
#include<iostream>
using namespace std;
int main()
{
    int a[5],i;
    for(i=0;i<5;i++)
        a[i]=i+1;
    for(i=0;i<5;i++)
        cout<<a[i]<<' ';
    return 0;
}

OUTPUT:

output

This post is licensed under CC BY 4.0 by the author.

Trending Tags