Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*6. Crie um algoritmo que leia o vetor com 10 números e some apenas os elementos positivos que estão nas
- posições pares. */
- #include <stdio.h>
- #include <stdlib.h>
- #define tam 10
- main(){
- int i;
- float vet[tam],soma=0;
- for (i=0; i < tam; i++){
- printf("Informe um numero: ");
- scanf("%f",&vet[i]);
- if (vet[i] >= 0 && i % 2 == 0){
- soma = soma + vet[i];
- }
- }
- printf("A soma deu %.0f\n",soma);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement