Why is the output not being displayed?

#include<stdio.h>
#include<stdlib.h>

int max(int a,int b)
{return (a>b?a:b);
}
int main()
{int i,n;
 
scanf("%d",&n);
 
int *a=(int *)malloc(n*sizeof(int));
int *m=(int *)malloc(n*sizeof(int));
 
 
 
for(i=0;i<n;i++)
scanf("&d",&a[i]);  
 
m[0]=a[0];
 
for(i=1;i<n;i++)
m[i]=max(m[i-1]+a[i],a[i]);     
 
printf("%d",m[n-1]);
 
return 0;
}

1 error that i can see on the 1st look is that…

this:-

scanf("&d",&a[i]);

should be this:-

scanf("%d",&a[i]);

i think the above error is the only 1…hope it helps…:slight_smile:

1 Like

thank u…i made a
silly mistake

//