Answer to Question #259862 in C++ for ahmed

Question #259862

1-Write a C++ program that delete the 5th

element from the following list

{1, 5, 4, 7, 10, 50, 21, 24}


1
Expert's answer
2021-11-01T18:45:46-0400


#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS