You must clean up and debug your code. Start with improved User Interaction.
int main() {
int n, capacity;
printf("Enter the count of the items: ");
scanf("%d", &n);
int *arr = (int *)malloc(n * sizeof(int));
for (int i = 0; i < n; i++) {
printf("Enter the weights of the item %d separated by space: ", i);
scanf("%d", &arr[i]);
}
You better use some struct in your code for better readability, like for a vehicle
struct Vehicle {
int identifier; int maxLoad;
int currentLoad;
}
Make more output, like in the comparision.
Visit some
Learn C tutorial to solve
your homework.