Created
January 12, 2014 21:49
-
-
Save zenatureza/8391043 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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