Array In C++:

An array is a data structure that contains a group of elements. Typically these elements are all of the same data type, such as an integer or string. Arrays are commonly used in computer programs to organize data so that a related set of values can be easily sorted or searched.

An array is a way of arranging things in rows and columns. When you buy things like a pack of cookies, a pack of toy cars, or even a carton of eggs, the items in the package are lined up to create an array. An array always has rows and columns. The rows are the horizontal lines that go from left to right.

#include <iostream>
using namespace std;

int main()
    int arr[3] = {1, 3, 6};
    //array index 0  1  2
    // int marks[6];

    // for (int i = 0; i < 6; i++)
    // {
    //     cout<<"Enter the marks of "<<i<<"th student"<<endl; 
    //     cin>>marks[i];
    // }
    // for (int i = 0; i < 6; i++)
    // {
    //     cout<<"Marks of "<<i<<"th student"<<marks[i]<<endl; 
    // }

    int arr2d[2][3] = {
    for (int i = 0; i < 2; i++)
        for (int j = 0; j < 3; j++)
            cout<<"The value at "<<i<<","<<j<<" is "<<arr2d[i][j]<<endl;
    return 0;

An array is a series of memory locations – or ‘boxes’ – each of which holds a single item of data, but with each box sharing the same name. All data in an array must be of the same data type . For example, imagine that a score table in a game needs to record ten scores.

An array is a collection of elements of the same type placed in contiguous memory locations that can be individually referenced by using an index to a unique identifier. Five values of type int can be declared as an array without having to declare five different variables (each with its own identifier).

C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.

Leave a Reply

For News Subscribe Us!

Can curiosity may end shameless explained. True high on said mr on come. An do mr design at little myself wholly entire though. Attended of on stronger or mr pleasure.

You have been successfully Subscribed! Ops! Something went wrong, please try again.

© 2022 Code With AM