forked from jrabhishek/dsa_assignment1
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path12.c
More file actions
45 lines (39 loc) · 708 Bytes
/
Copy path12.c
File metadata and controls
45 lines (39 loc) · 708 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
42
43
44
45
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *array,i,n,c,j,*array_result,k;
printf("enter size of array\n");
scanf("%d",&n);
array = (int*)malloc(n * sizeof(int));
array_result = (int*)malloc(n * sizeof(int));
printf("enter elements of array\n");
for ( i = 0; i < n; ++i)
{
scanf("%d",(array+i));
/* code */
}
int p,previous;;
for (i = 0; i < n; ++i)
{
/* code */
p=1;
previous = 1;
for (k = 0; k < i; ++k)
{
/* code */
previous *= *(array+k);
}
for (j = i+1; j < n; ++j)
{
/* code */
p *= *(array+j);
}
i[array_result] = p * previous;
}
printf("resulted array\n");
for ( i = 0; i < n; ++i)
{
printf("%d\n",*(array_result+i));
}
}