Q:

How do I print out 100 numbers in an array then add them using C

I'm trying to print out 100 numbers from an array using a loop and then add them all together.  So far I have:
#include <stdio.h>
#include <stdlib.h>

int main(){
    int* number = malloc(101 * sizeof(int));
    int num = 0;
    number[num] = 1;

    while (number[num] <= 100){
        printf(" %d\n ", number[num]);
        num = num +1;
        number[num] = number[num]+1;

    }

    return 0;
}

but this just prints 1 once. 

A:

Try this:
#include <stdio.h>

int main () {

   int n[ 100 ]; /* n is an array of 100 integers */
   int i,j;
   int sum = 0;

   /* initialization */
   for ( i = 0; i < 100; i++ ) {
      n[ i ] = i + 100;   /* set element at location i to i + 100 */
   }

   /* output each array element's value */
   for (j = 0; j < 100; j++ ) {
      printf("Element[%d] = %d\n", j, n[j]);
      sum += n[j];
   }

   printf("Sum of Elements = %d\n", sum);
   return 0;
}

Remember that you should declare an array, then initialize it, print it out and after all print out the sum

