title: Counting combinations in c or in python
body: <p>Hello I looked a bit on this topic here but I found nothing that could help me.</p>
  
  <p>I need a program in Python or in C that will give me all possible combinations of a and b that will meet the requirement n=2*a+b, for n from 0 to 10. a, b and n are integers.
  For example if n=0 both a and b must be 0. For n=1 a must be zero and b must be 1, for n=2 a can be 1 and b=0, or a=0 and b=2, etc.</p>
  
  <p>I'm not that good with programming. I made this:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void){
      int a,b,n;
      for(n = 0; n &lt;= 10; n++){
          for(a = 0; a &lt;= 10; a++){
              for(b = 0; b &lt;= 10; b++)
                  if(n == 2*a + b)
                      printf("(%d, %d), ", (a,b));
          }
          printf("\n");       
      }
  }
  </code></pre>
  
  <p>But it keeps getting strange results like this:</p>
  
  <pre>
  (0, -1079628000), 
  (1, -1079628000), 
  (2, -1079628000), (0, -1079628000), 
  (3, -1079628000), (1, -1079628000), 
  (4, -1079628000), (2, -1079628000), (0, -1079628000), 
  (5, -1079628000), (3, -1079628000), (1, -1079628000), 
  (6, -1079628000), (4, -1079628000), (2, -1079628000), (0, -1079628000), 
  (7, -1079628000), (5, -1079628000), (3, -1079628000), (1, -1079628000), 
  (8, -1079628000), (6, -1079628000), (4, -1079628000), (2, -1079628000), (0, -1079628000), 
  (9, -1079628000), (7, -1079628000), (5, -1079628000), (3, -1079628000), (1, -1079628000), 
  (10, -1079628000), (8, -1079628000), (6, -1079628000), (4, -1079628000), (2, -1079628000), (0, -1079628000), 
  </pre>
  
  <p><a href="http://ideone.com/y9vM8" rel="nofollow">ideone</a></p>
  
  <p>Any idea what is wrong?</p>
  
  <p>Also if I could do this for Python it would be even cooler. :D</p>