forked from CPRO-Session1/Assignment4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharraySum.c
More file actions
42 lines (30 loc) · 703 Bytes
/
arraySum.c
File metadata and controls
42 lines (30 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//Clarke Littlejohn
//Arraysum of previous elements
//i am not sure if this correct code
#include<stdio.h>
int main(){
int arraySize;
printf("This program will give you the sum of the the prevouis elements in the array.\nEnter number to set the size of the Array.");
scanf("%d",&arraySize);
int array1 [arraySize];
int array2 [arraySize];
int i=0;
int j,sum;
printf("Now enter the values you want to be summed.\n");
while(i<arraySize){
scanf("%d",&array1[i]);
i++;
}
for(i=0;i<arraySize;i++){
sum=0;
for(j=0;j<arraySize;j++){
if(i!=j){
sum+=array1[j];
}
}
array2[i]=sum;
}
for(i=0;i<arraySize;i++){
printf("%d\t",array2[i]);
}
}