'linear search in array to add the values of matched indexes for parallel arrays

int priority[item] = {1,3,2,1,3}; //item is a user inputted number max can be 10
int cost[item] = {200,333,111,444,42};// parallel values of the items
printf("What priority do you want to filter by? [1-3]: ");
scanf("%d", &select); select can be a value of 1-3

I have to find all the items with priority 1 and total their cost

Filter: by priority (1)

Total: $311



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source