0
It is intended to elaborate a program that asks the user for integer numbers and stores them in an array, this procedure is repeated until the user type the value zero.
At the end the program should show all the values you entered. You should also consider the following assumptions: - Guard on the vector, only the values in the range [100, 500]; - The vector has a maximum capacity of 15 elements; - When the capacity reaches the limit should warn the user.
It must develop the following sub-programmes: - A function with the prototype, int lerVectorDeInteiros(int tabelaInteiros[], int nElementos)
, that will handle the collection of integer numbers, store these values in the vector , and consider all previous assumptions.
At the end the function should return the amount of elements inserted into the vector. - A procedure with the following prototype, void mostrarTabelaInteiros(int tabelaInteiros[], int nElementos)
, which will display only user input values on the screen.
Code done 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;
}
What have you done? What is your question?
– Pablo Almeida
Good afternoon Pablo, nothing, I’m looking at the problem because I don’t even understand where to start
– Diogo Pereira
#define MAX 15 int lerVectorDeintegers(int *); int main() { int vector[MAX]; int quantityElements = 0; quantityElements =lerVectorDenters(vector); printf("The amount of elements that have been inserted into the vector are %d", quantityElements); Return 0; } int readVectorDeintegers(int vector[MAX]){ int i; int temp = 0; int counter = 0; for(i=0; i<MAX; i++){ scanf("%d", &temp); if(temp > 99 && temp < 501){ vector[i] = temp; counter++; } } counter; }
– Diogo Pereira
This code is that you have already worked out to try to solve the problem ? If yes add it to the question
– Isac
I’m new here, how do I do it?
– Diogo Pereira
I voted to close the question because you only put here the statement of the work, and did not even deign to put a word of your text or to show what you have already done. Remember that the Stackoverflow PT community is not a free college work resolution service.
– Isac
Isac I understand and realize, sorry, I’m new here. Thank you! D
– Diogo Pereira
Dude, you have to add your code and also have to specify to us what your question is, I suggest you edit the question and add your question, to add a code, just copy it from the used IDE, then select it whole and click the {} button, okay ;)
– Gabriel A. S. Braga
Exercicio Vetores, estou encalhado
-> you will not be able to solve this with programming.– Oralista de Sistemas