C Program that reads and Stores a series of integers

void main() {
    int N,i,sum=0,temp;
    printf("Please enter value of N\n");
    scanf_s("%d", &N);
    int *arr = (int*)malloc(sizeof(int)*N);
    for (i = 0; i < N; i++) {
        printf("Please %d value of array \n",i+1);
        scanf_s("%d", &temp);
        arr[i] = temp;
        sum += temp;
    }
    printf("Sum Of N Elemetes In Array Is %d", sum);
}

Leave a Comment