#include<stdio.h>
int main(void) {
int b,c=0;
for(int i=0;i<5;i++)
{
scanf("%d",&b);
c=c+b;
if(c>0)
{
printf("%d\n",b);
}
else if(c<0)
{
break;
}
}
return 0;
}
See my code and tell what is wrong in it. and plz correct it also
since we dont know how many time we would have to print b, use while loop and if(c>=0) you need to print b but you are only printing it for c > 0
Corrected code with comments