Quote:
i am getting addtionaly 3 zeros in the output
Because you need to correct the printing part too.
for(i=0;i<n/2;i++)
printf("%d ",b[i]);
[Update]
A little analyze show that
a
is never reused once
b
is calculated => you don't need
b
#include<stdio.h>
#include <stdlib.h>
int main()
{
int i,j,n,a[9999],b[9999];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0,j=n-1;i<j;i++,j--)
{
b[i]=a[i]+a[j];
a[i]=a[i]+a[j];
}
for(i=0;i<n/2;i++)
printf("%d ",b[i]);
printf("%d ",a[i]);
}
the memory footprint have just been divided by 2 and it is possible to go further.