I am new into solving problems in programming,this is some problem from onlinejudge that i want to solve,
here is the problem :
you need to sum all of the inputs
sample input1:
1 -184
sample output1:
-184
sample input2 :
10 439 298 -935 72 636 774 -509 -568 228 47
sample output2 :
482
and here is my code :
main() {
int num,sum;
char ch;
while(ch != 10) {
scanf("%d",&num);
ch = getchar();
if(num != 1 || 0 ) {
sum += num;
}
}
printf("%d",sum);
return 0;
}
i am little bit lost here and wondering how to ignore those integer(1,0,10) my code worked on first sample,but not on the other one.
any solution?