It is intended to elaborate a program that asks integers to the user and saves them in a vector, this procedure is repeated until the user enters the value zero.
At the end the program should show all the values that the user entered. You should also consider the following assumptions: - Keep in the vector, only the values in the interval [100, 500]; - The vector has a maximum capacity of 15 elements; - When the capacity reaches the limit, you must inform the user.
You should develop the following subprograms: - A function with the prototype, int lerVectorDeInteiros(int tabelaInteiros[], int nElementos)
, which will handle the collection of integers, store those values in the vector, and consider all previous assumptions.
At the end the function should return the amount of elements inserted in the vector. - A procedure with the following prototype, void mostrarTabelaInteiros(int tabelaInteiros[], int nElementos)
, which will display only the values entered by the user on the screen.
Code made so far:
#include <stdio.h>
#define MAX 15
int lerVectorDeInteiros(int *);
int main ()
{
int vetor[MAX];
int quantidadeElementos = 0;
quantidadeElementos =lerVectorDeInteiros(vetor);
printf("A quantidade de elementos que foram inseridos no vetor sao %d", quantidadeElementos);
return 0;
}
int lerVectorDeInteiros ( int vetor[MAX] )
{
int i;
int temp = 0;
int contador = 0;
for ( i = 0; i < MAX; i++ )
{
scanf("%d", &temp);
if(temp > 99 && temp < 501)
{
vetor[i] = temp;
contador++;
}
}
return contador;
}