Skip to content
Snippets Groups Projects
Commit 8d64b220 authored by Pirahalathan Premachandran's avatar Pirahalathan Premachandran
Browse files

Aufgabe 5.3 fertig

parent 94002505
No related branches found
No related tags found
No related merge requests found
......@@ -22,11 +22,13 @@ int getNextIndexToStoreProductTo(int storageArr[], int storageArrSize) {
* is full, return -1.
*/
int index = 0;
while (index ) {
while (index < storageArrSize) {
if (storageArr[index] <= 0) {
return index;
}
index++;
}
return index;
return -1;
}
int findProductIn(int storageArr[], int storageArrSize, int productId) {
......@@ -34,5 +36,12 @@ int findProductIn(int storageArr[], int storageArrSize, int productId) {
* It should return the first occurrence of a given product id.
* If the id is not found, it should return -1.
*/
int idx = 0;
while(idx < storageArrSize) {
if(storageArr[idx] == productId) {
return idx;
}
idx++;
}
return -1;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment