getting wrong answer

#include<stdio.h>
int main(){
int n,c,t,k,a[100];
long unsigned int candy;
for(scanf("%d",&t);t>0;t–){
scanf("%d%d",&n,&candy);
for(k=0,c=0;k<n;k++) {scanf("%d",&a[k]); c=c+a[k];}
if(candy<c) printf(“No”);
else printf(“Yes”);}
return 0;
}

it’s not working fine for input from problem statement - http://ideone.com/jE9CaY

1 Like

I edited it a bit. changed %d to %llu.

But check here , the value of t drops from 2 to 0 in the loop. I am confused from this.

I changed long unsigned int candy to unsigned long long candy, see http://ideone.com/37r8Bz maybe some C++ guru can describe in detail, I’m Java guy…

The mistake is small.

There is missing ‘\n’ in both printf
correction:
printf(“Yes\n”); and printf(“No\n”);

If still there is problem, comment below.