1
Mine ifs
within the for
vector are bugging and at the end of the execution of the program showing a completely random number. Follow the code:
//Exercicio_08
#include <conio.h>
#include <stdio.h>
#define max 8
//Codigo
main(){
int i;
int a[max];
int par;
par = 0;
//entrada vetor A
for(i=1; i<=max; i++){
printf("\nDigite o %i elemento do vetor A: ", i);
scanf("%i",& a[i]);
}
//mostra o vetor A
printf("\n");
for(i=1; i<=max; i++){
printf("%i ", a[i]);
}
for(i=1; i<=max; i++){
if(a[i] % 2 == 0){
printf("\nPar: %i", & a[i]);
par = par + 1;
}
}
printf("\nQuantidade de pares: %i", &par);
getch();
}
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero
Be careful because in c the vectors start at 0 Note that from (1 to x being x <= 8 )has the same range as (0 to x being x < 8)
– le314u