Advertisement
lButcherl

Vetor 05

Oct 29th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. /*5. Elabore um algoritmo que leia 10 números do teclado e os armazene em um vetor. Em seguida, leia um
  2. número n qualquer e apresente na tela a quantidade de vezes que o número n aparece no vetor. */
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #define tam 10
  7.  
  8. main(){
  9.        int i,vez=0;
  10.        float vet[tam],num;
  11.        for (i=0; i < tam; i++){
  12.            printf("Informe um numero: ");
  13.            scanf("%f",&vet[i]);
  14.            }
  15.            printf("Informe um numero qualquer: ");
  16.            scanf("%f",&num);
  17.            for (i=0; i<tam;i++){
  18.                if (vet[i] == num){
  19.                           vez ++;
  20.                           }
  21.                       }
  22.                       printf("O numero %.0f aparece %i vez(es) no vetor.\n",num,vez);
  23.                       system("pause");
  24.                       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement