Created
August 15, 2013 04:13
-
-
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.
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> | |
/* ///////////////////////////////////// | |
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