The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Hello all. This is my first time using array not too sure what's wrong with my code. Â I have attached the assignment.Â
Â
#include
using namespace std;
Â
int main();
{
const int SIZE = 10;
int ar[SIZE];
srand (time(0));
int element;
for (int i = 0; i {
element = rand()%100 + 1
array [i]= element;
for (int l = 0, r = size - 1; ; l ++, r _ _ )
Â
}
Â
return 0;
}
Â
Â
Â
Â
CS111Fall 2016Kazumi SlottLab 9-3arraySwap.cppPut all your code in main.0.Declare a constant called SIZE for the size of the array (10).1.Create an array with 10 slots (use SIZE).2.Fill the array with 10 random numbers between 1 and 100.3.Print the array.4.Reverse the contents of the array.Do not create a second array.Hints:Swap each pair from outside.Use 2 indices (l, r).for(int l = 0,r = SIZE – 1; ….; l??,r??)You need a variable to store one of the numbers you are swapping.l = 0swapr = SIZE -1Original1010052211953351122Reverse22151339511225100105.Print the array again.
Attachments: