0
C program
Guys, could anyone help me solve this task: "Create program which contains function v 'increaseANDexpand' that expands array of integers for new element which is added after every odd number in array. New element which is inserted has 3 times the value of the odd number after which it is inserted. Ex. if odd number from array is 3 insert 9 after him, if odd number from array is 5 insert 15 after him etc..
2 Respuestas
+ 2
Hello and welcome to sololearn
We can't do work homeworks here so you have to show your attempt so that we may help you :)
What you have to do just paste your code here
https://www.sololearn.com/post/75089/?ref=app
https://www.sololearn.com/discuss/333866/?ref=app
0
1: #include<stdio.h>
2: main()
3: {
4: int x[5]={1,2,3,4,5};
5: int i,y,poz,n=5;
6:
7: printf("Stampaju se elementi niza:");
8: for(i=0;i<n;i++)
9: {
10: printf("\n%d", x[i]);
11:
12: }y=5;
13:
14:
15: for(i=0;i<n;i++)
16: if(x[i]%2!=0)
17: {
18:
19: poz=i+1;
20: x[i+1]=y;
21: if(x[i+1]%2!=0)
22: i++;
23: n++;
24:
25:
26:
27: }
28: for(i=n;i>=poz;i--)
29: x[i]=x[i+1];
30: x[poz-1]=y;
31:
32:
33:
34:
35:
36:
37:
38: printf("Stampa se modifikovani niz:");
39: for(i=0;i<n;i++)
40: printf("\n%d", x[i]);
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53: }
Was trying, but could not make it:(