-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp12.c
48 lines (41 loc) · 964 Bytes
/
p12.c
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
42
43
44
45
46
47
48
// #include<stdio.h>
// void display_array(int a[],int n);
// int main(){
// int n;
// printf("enter the size of the array; ");
// scanf("%d",&n);
// int a[n];
// // display_array(a[n]);
// for(int i=0;i<n;i++){
// scanf("%d",&a[i]);
// }
// display_array(a,n);
// }
// void display_array(int a[],int n){
// for ( int i=0;i<n;i++)
// {
// printf("%d ",a[i]);
// }
// }
#include<stdio.h>
void sum(int a[],int n);
int main(){
int n;
printf("enter the size of the array;");
scanf("%d",&n);
int a[n];
for (int i=0; i<n;i++){
scanf("%d",&a[i]);
}
sum(a,n);
return 0;
}
void sum(int a[],int n){
int s=0;
for ( int i = 0; i < n; i++)
{
/* code */
s=s+a[i];
}
printf("sum of elements of array= %d",s);
}