Skip to content

Instantly share code, notes, and snippets.

@zenatureza
Created January 12, 2014 21:49
Show Gist options
  • Save zenatureza/8391043 to your computer and use it in GitHub Desktop.
Save zenatureza/8391043 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
int i=0;
int func(int n, int *vet);
void main(){
printf("Digite quanto valores tem o vetor: ");
int n;
scanf("%d", &n);
getchar();
int vet[n];
for(;i<n;i++){
printf("%d) ", i+1);
scanf("%d", &vet[i]);
}
int result = func(n, vet);
printf("\nO número de elementos pares desse vetor é: %d\n", result);
}
int func(int n, int *vet){
int pares=0;
for(i=0;i<n;i++){
if(vet[i] % 2 == 0)
pares++;
}
return pares;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment