Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*5. Elabore um algoritmo que leia 10 números do teclado e os armazene em um vetor. Em seguida, leia um
- número n qualquer e apresente na tela a quantidade de vezes que o número n aparece no vetor. */
- #include <stdio.h>
- #include <stdlib.h>
- #define tam 10
- main(){
- int i,vez=0;
- float vet[tam],num;
- for (i=0; i < tam; i++){
- printf("Informe um numero: ");
- scanf("%f",&vet[i]);
- }
- printf("Informe um numero qualquer: ");
- scanf("%f",&num);
- for (i=0; i<tam;i++){
- if (vet[i] == num){
- vez ++;
- }
- }
- printf("O numero %.0f aparece %i vez(es) no vetor.\n",num,vez);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement