int n[40]={0},i,j,top;
for(i=0; i<40 && n[i]!=-1; i++)
scanf("%d",&n[i]);
top = i-1;
for(i=0;i<=top;i++)
{
for(j=0;j<n[i];j++)
printf("|");
printf("\n");
}
Type: Posts; User: sachin.leo
int n[40]={0},i,j,top;
for(i=0; i<40 && n[i]!=-1; i++)
scanf("%d",&n[i]);
top = i-1;
for(i=0;i<=top;i++)
{
for(j=0;j<n[i];j++)
printf("|");
printf("\n");
}
may be there is some buffer problem. try cleaning buffer using fflush(stdin);
moreover you are just taking ans in 1 character but you are taking a string as an input, you are wasting resources dude....