Question: a. This program is supposed to write 30 20 10, but it doesn't. Find all of the bugs and show a fixed version of the
a. This program is supposed to write 30 20 10, but it doesn't. Find all of the bugs and show a fixed version of the program:
int main()
{
intarr[3]={5,10,15}; int* ptr = arr; *ptr = 10; // set arr[0] to 10 *ptr + 1 = 20; / set arr[1] to 20 ptr += 2; ptr[0] = 30; // set arr[2] to 30
while (ptr >= arr)
}
ptr--; cout << ' ' << *ptr; // print values }
cout << endl;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
