fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int i;
  6. int total = 0;
  7. int primes[6] = {1,2,3,5,7,11};
  8.  
  9. for(i=0;i<6;i++) {
  10. total = total + primes[i];
  11. printf("primes[%d] = %d\n", i, primes[i]);
  12. }
  13. primes[0] = total;
  14. printf("The sum of the array is %d \n", primes[0]);
  15. return 0;
  16. }
Success #stdin #stdout 0.01s 5288KB
stdin
45
stdout
primes[0] = 1
primes[1] = 2
primes[2] = 3
primes[3] = 5
primes[4] = 7
primes[5] = 11
The sum of the array is 29