
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This c++ document provides the code for a program that reverses the contents of an array. The program initializes an integer array 'a' with ten elements, creates two pointers 'p' and 'q' that point to the first and last elements of another integer array 'b' respectively. The 'for' loop is used to swap the elements of 'a' and 'b' by dereferencing the pointers and incrementing/decrementing them accordingly. The reversed array 'b' is then displayed using the 'cout' statement.
Typology: Exercises
1 / 1
This page cannot be seen from the preview
Don't miss anything!

#include<conio.h> #include<iostream.h> void main (void) { int a[10]={1,2,3,4,5,6,7,8,9,10}; int b[10]; int p,q; clrscr(); p=&a[0]; q=&b[9]; for (int i=0;i<10;i++) { q=p; p++; q--; } for (i=0;i<10;i++) { cout<<" "<<b[i]; } getch(); }