1-Write a C++ program that delete the 5th
element from the following list
{1, 5, 4, 7, 10, 50, 21, 24}
#include<iostream>
#include<string>
using namespace std;
int main(){
int list[] ={1, 5, 4, 7, 10, 50, 21, 24};
cout<<"Current list:\n";
for(int i=0;i<8;i++){
cout<<list[i]<<" ";
}
cout<<"\n\nAfter deleting the 5th element from the list:\n";
for(int i=4;i<7;i++){
list[i]=list[i+1];
}
for(int i=0;i<7;i++){
cout<<list[i]<<" ";
}
cin>>list[0];
return 0;
}
Comments
Leave a comment