Could someone explain this to me more throughly The more det
Could someone explain this to me more throughly? The more detail the better. I need to know how to read these things for my test tomorrow. What are the outputs?
Solution
#include <stdio.h>
void f(int arr[],int n)
{
int i;
for(i=0;i<n/2;i++)
{
arr[n-1-i] += arr[i];
}
}
int main(void)
{
int i;
int list[] = {0,2,4,6,8,9,7,5,3,1};
f(list,10);
for(i=0;i<10;i++)
printf(\"%d\\t\",list[i]);
printf(\"\ \");
f(list,6);
for(i=0;i<10;i++)
printf(\"%d\\t\",list[i]);
printf(\"\ \");
f(list,2);
for(i=0;i<10;i++)
printf(\"%d\\t\",list[i]);
printf(\"\ \");
return 0;
}
Output
arr[0] to arr[4] will remain same and next 5 elements of arr will be 17,13,9,5,1
