Solution to write c++ programm to swap first and last element of an integer 1-D array - Sikademy
Author Image

Archangel Macsika

write c++ programm to swap first and last element of an integer 1-D array

The Answer to the Question
is below this banner.

Can't find a solution anywhere?

NEED A FAST ANSWER TO ANY QUESTION OR ASSIGNMENT?

Get the Answers Now!

You will get a detailed answer to your question or assignment in the shortest time possible.

Here's the Solution to this Question


using namespace std; //write c++ programm to swap first and last element of an integer 1-D array int main() { int arr[]={1,3,5,7,9}; int n=0,l; l = sizeof(arr)/sizeof(arr[0]); cout<<"\n\tArray before swapping: "; for(n=0;n<l;n++) cout<<arr[n]<<", "; n=arr[0]; arr[0] = arr[l-1]; arr[l-1] = n; cout<<"\n\tArray before swapping: "; for(n=0;n<l;n++) cout<<arr[n]<<", "; return(0); }

Related Answers

Was this answer helpful?

Join our Community to stay in the know

Get updates for similar and other helpful Answers

Question ID: mtid-3-stid-44-sqid-1077-qpid-73