in fedora tell me the program for deletion of an array on c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

in fedora tell me the program for deletion of an array on c++

13th Jul 2016, 7:54 PM
Avinash Singh
Avinash Singh - avatar
7 Answers
+ 1
first of all weather you be in fedora or linux or Mac or Windows the code wont change much and then what type of deletion are you talking about.... I mean deletion of element in an array or deletion of an array
13th Jul 2016, 7:57 PM
Vedant Patadia
Vedant Patadia - avatar
+ 1
You cannot delete a single element in a array, you have to recreate the array with one number less and then copy the contents of the old array to the new array. Or you can use std::vector in vector header.
13th Jul 2016, 8:18 PM
this->getName()
0
If the array is dynamically created(using a pointer) you should use delete[] nameOfArray; If it was a static array(dont confuse with static keyword) the array is removed from memory when it goes out of scope.
13th Jul 2016, 8:05 PM
this->getName()
0
deletion of an element in an array
13th Jul 2016, 8:14 PM
Avinash Singh
Avinash Singh - avatar
0
plz give the whole program syntax
13th Jul 2016, 8:15 PM
Avinash Singh
Avinash Singh - avatar
0
//try this #include<iostream> #include<conio.h> using namespace std;   int main() {      int i,inputarray[10],no,pos;      cout<<"Enter 10 data elements in array: ";    for(i=0;i<10;i++)    {         cin>>inputarray[i];    }    cout<<"\nEnter position of element to delete: ";    cin>>pos;      if(pos>10)    {         cout<<"\n position value is not in range: ";    }    else    {        --pos;        for(i=pos;i<=9;i++)        {             inputarray[i]=inputarray[i+1];        }          cout<<"\n\nNew data in array: ";          for(i=0;i<9;i++)        {             cout<<inputarray[i];             cout<<" ";        }    } } //actually I just made it here so you'll need to //eliminate syntax errors, if any
14th Jul 2016, 6:58 AM
Vedant Patadia
Vedant Patadia - avatar
0
thank you
14th Jul 2016, 1:42 PM
Avinash Singh
Avinash Singh - avatar