Created
December 15, 2016 13:36
-
-
Save jeffotoni/723c6bafbbb5f53dd98094c85e6999d8 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 <stdio.h> | |
#include <stdlib.h> | |
#define TAMANHO 5 | |
/* | |
11. Crie um programa que contenha um array contendo 5 elementos inteiros. Leia esse array | |
do teclado e imprima o endereço das posições contendo valores pares. | |
*/ | |
int main() | |
{ | |
int i = 0 , vetor[TAMANHO], j=0; | |
int *vetorPonteiro = malloc (TAMANHO * sizeof (int)); | |
for (i = 0 ; i < TAMANHO ; i++ ) | |
{ | |
printf("Digite o %d° número: " , i); | |
scanf("%d" , &vetor[i]); | |
*(vetorPonteiro+i) = vetor[i]; | |
} | |
printf("O valores pares de endereço de memória\n\n"); | |
//for (i = 0 ; i < TAMANHO ; i++ , j = *vetorPonteiro++ ) | |
i = 0; | |
while( j = *vetorPonteiro++ ) | |
{ | |
if( j % 2 == 0 ) | |
{ | |
printf("\nSua posição é = %d , %d | Endereço de memória = %p" , i, j, &vetorPonteiro[i]); | |
} | |
i++; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment