delete an element from an array:
for (int i = index; i < /* length */; i++)
{
array[index] = array[index+1];
array[length-1] = 0;
}
size of an array:
another way:
for (int i = index; i < /* length */; i++)
{
array[index] = array[index+1];
array[length-1] = 0;
}
size of an array:
#include<iostream>
using namespace std;
int main()
{
int a[]={1,2,3,4,5,6};
int size;
size=sizeof a/sizeof(int); //total size of array/size of array data type
cout<<size;
return 0;
}
another way:
int
a[]= {1, 5, 8, 9, 6, 7, 3, 4, 2, 0};
int
asize =
sizeof
(a) /
sizeof
(a[0]); //size of the array
No comments:
Post a Comment