<h2>C: <strike>150</strike> 138 - (100+50) = -12</h2> a,b,c;main(d){for(scanf("%d ",&a);~scanf("%c%d ",&d,&b);a=d^43?d%5?d%2?a/b:a*b:a-b:a+b);for(;a;)for(b=a--;b;b/=10)c+=b%10;printf("%d",c);} Very shamefully stealing @Fors answer from here to do the expression evaluation: http://codegolf.stackexchange.com/a/11423/13877 Sample usage: ./a.exe <<< "5 + 7" 51