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. An array is a variable that can store multiple values. For example, if you want to store 5 integers, you can create an array for it.
Syntax :
datetype arrayName [ arraySize ] ;
Example :
int arr [ 5 ] ;
This program demonstrates the use of arrays in C++ and prints out the elements of two different arrays:
#include<iostream> using namespace std; int main() { int a[5]={10,20};//10 20 0 0 0 int b[]={1,2,3,4,5}; for(int x:a) cout<<x<<endl; cout<<"------------"<<endl; for(int x:b) cout<<x<<endl; cout<<"Count :"<<sizeof(a)/sizeof(int); return 0; }
10 20 0 0 0 ------------ 1 2 3 4 5 Count :5To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions