0
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
int vetor_y1();
int main(){
setlocale(LC_ALL, "Portuguese");
int i,j;
printf("Inf. o tamanho do vetor: ");
scanf("%d",&i);
int vetor[i];
for(j=0;j<i;j++){
printf("Inf. o %dº valor: ",j+1);
scanf("%d",&vetor[j]);
}
vetor_y1(vetor, j);
printf("\n");
system("pause");
return 0;
}
int vetor_y1(int vetor[], int j){
int i=j;
int vetor_y1[j];
for(j=0;j<i;j++){
vetor_y1[j]=vetor[j];
}
printf("Vetor Y\n");
for(j=0;j<i;j++){
if(vetor_y1[j]>=10 && vetor_y1[j]<=40){
printf("%d ",vetor_y1[j]);
}
}
}
Without allocating what? Is there any requirement for the code to be like this? It can be much simpler than this.
– Maniero
The vector received in the function is a pointer, so when it changes the function already changes the values, and so it makes no sense to return
– Isac
I am learning, so I would like to make the vector y1 return to main, and printar na main, but it is not necessary since I did the exercise, I just have this doubt and I would like to learn but I could not
– Braian Freitas
There is no requirement, just want to learn to return it and printar na main
– Braian Freitas