Online C++ Compiler

Run your C++ code online with this online executor

#include <iostream> using namespace std; int main() { int array[10]={1,2,2,7,8,2,6,9,0,1};//declaring an array int size=10; int n = 2;//specific value which we have to remove for(int i=0 ; i<size ; i++) { cout<<array[i]; //printing the original array } cout<<endl; int i=0; while( i <size) //declaring a loop { if(array[i]==n) //checking if element has the value that has to be { //delted if(i<(size-1)) //cheking that our element is not on last position { for(int j=i ; j<(size-1) ; j++) array[j]=array[j+1]; //shifting the elements one position size--; // back to remove specified element } } else i++; } for(int i=0 ; i<size ; i++){ cout<<array[i]; //printing updated array } return 0; }


If the code takes user input, put it here. For multiple inputs, one per line
  • C++ tutorials