Function vector/array

  • File name: Function vector/array
  • Size: 243 b
yes /

Download

The function change modifies the vector v is passed as a parameter from main so that pairs of vector elements are multiplied by 3 and 2 odd elements.


 



#include <stdio.h>

void cambio(int v[]){
    int i;
    for(i=0;i<40;i++){
        if(v[i]%2==0)v[i]*=3;
        else v[i]*=2;
        printf("%d ",v[i]);
    }
}

int main(){
int i;
int v[40];
for(i=0;i<40;i++)v[i]=i;
cambio(v);
return 0;
}

 

More exercices in https://www.youtube.com/channel/UCK05KbyByXPCMRJEqyL4VXw/videos

No ratings yet - be the first to rate this.

Add a comment

You're using an AdBlock like software. Disable it to allow submit.