Skip to content

Instantly share code, notes, and snippets.

@valdiney
Created August 15, 2013 04:13
Show Gist options
  • Save valdiney/6238207 to your computer and use it in GitHub Desktop.
Save valdiney/6238207 to your computer and use it in GitHub Desktop.
Somando todos os valores de um vetor. Gostaria de apresentar somente a soma dos valores.
#include<stdio.h>
#include<stdlib.h>
/* /////////////////////////////////////
Somando todos os valores de um vetor
Estudante: Valdiney França
*//////////////////////////////////////
////////////////////////////////////////////
// Somando todos os valores de um vetor...
///////////////////////////////////////////
int main() {
int vetor[5], cont, result = 0;
///////////////////////////////////////////
// Recebendo os valores de entrada...
//////////////////////////////////////////
for(cont = 0; cont < 5; cont++) {
printf("Entre com um valor: ");
scanf("%d", &vetor[cont]);
}// end loop...
///////////////////////////////////////////
// Apresentando e somando os valores...
//////////////////////////////////////////
for(cont = 0; cont < 5; cont++) {
result += vetor[cont];
printf("%d = ", result);
}// end loop...
getche();
}// end main...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment