In: Computer Science
Write an algorithm (in pseudocode, with proper indentation for blocks of code in loops or conditional statements) that finds and returns the location of the first negative integer in a sequence of integers.
Answer :
Let code pseudocode in C++.
int firstNegativeIndex(int list[], int n) {
int index = 0;
for(index; index < n; index++) {
if(list[index] < 0) {
break;
}
}
return index;
}
Explanation :
Here list is the array of integer and n is the size of list.
Hope you like it
Any Query? Comment Down!
I have written for you, Please up vote the answer as it encourage us to serve you Best !