Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int somaVetor(int vetor[], const int n) {
- int soma = 0;
- int *const finalVetor = vetor + n;
- int *ponteiro = vetor;
- while (ponteiro < finalVetor) {
- soma += *ponteiro;
- ++ponteiro;
- }
- return soma;
- }
- int main (void) {
- int somaVetor(int vetor[], const int n);
- int vetor[10] = {5, 5, 5, 5, 5, 5, 5, 5, 5, 5};
- printf("Soma = %d\n", somaVetor(vetor, 10));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement