title: The program stops and don't excute the Threads Why?
body: <p>I wrote a program which takes number of numbers from the user and then allow to enter the numbers , then create two threads one to calculate the sum and the other to calculate the Avg
  but after giving the numbers the program stops and gives error Why?</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;Windows.h&gt;
  #include&lt;stdlib.h&gt;
  
  int count ;
  
  DWORD WINAPI Sum(PVOID s)
  {
      int *sum=(int *)s;
      DWORD c=0;
      for(int i=0;i&lt;count;i++)
          c+=sum[i];
      return c;
  }
  
  DWORD WINAPI Avg(PVOID s)
  {
      int *var=(int *)s;
      DWORD avg=0;
      avg=(*var/count);
      return avg; 
  }
  
  int main()
  {
      printf("Enter the number of numbers\n");
      scanf("%d",&amp;count);
      int *s = (int*)malloc(sizeof(int)*count);
      printf("now enter the numbers\n");
      for(int i=0;i&lt;count;i++)
          scanf("%d",s[i]);
  
      HANDLE t1 , t2;
      DWORD id1 , id2 , c1 , c2;
      t1 = CreateThread(NULL , 0 , Sum , s , 0 , &amp;id1);
      WaitForSingleObject(t1,INFINITE);
      GetExitCodeThread(t1 , &amp;c1);
      printf("The Sum = %d", c1);
      t2 = CreateThread(NULL , 0 , Avg , (PVOID*)&amp;c1 , 0 , &amp;id2);
      WaitForSingleObject(t2,INFINITE);
      GetExitCodeThread(t2 , &amp;c2);
      printf("The AVgerage = %d", c2);
      return 0;
  }
  </code></pre>
  
  <p>If any one would help me  will be Thanksfull.
  Thanks
  So T update the program and now it's work but the Avg is wrong and that's because when I try to print it like this printf("The AVG=%f\n",c2) the result is zero  Why?</p>