I leave here the code of a vector that I have made but I have no idea why it does not do what it should.
I have put a variable called cantidad
, and a vector[cantidad]
so that the user can manage the values of the array but only puts up to 6 values.
For example: How many values do you want in the array ?: 7, then enter up to 6 ..
#include <stdio.h>
int main()
{
printf("ARRAY VARIABLE\n\n");
int cantidad;
int vector[cantidad];
printf("Introduzca la cantidad de valores del array: ");
scanf("%d",&cantidad);
for(int i=0;i<cantidad;i++)
{
printf("%d valor del array: ",i+1);
scanf("%d",&vector[i]);
}
printf("\nValores introducidos\n\n");
for(int i=0;i<cantidad;i++)
{
printf(" %d",vector[i]);
}
return 0;
}