so i have this linear search code, mostly i know everything that happens in that code. But now I struggle at the end... I tried to google it but somehow did not find anything....
Here is the Code
#include <iostream>
using namespace std;
int search(int k, int array[], int size)
{
int i;
for (i = 0; i < size; i++)
if (array[i] == k)
return i;
return -1;
}
int main(void)
{
int array[] = { 2, 3, 4, 10, 40 };
int k = 10;
int size = sizeof(array) / sizeof(array[0]);
cout << size << endl;
int result = search(k, array, size);
(result == -1)
? cout << "K gibt es nicht"
: cout << "K Gefunden: " << result;
return 0;
}
So my question.. What does the :
and the ?
before the cout
mean?
? cout << "K gibt es nicht"
: cout << "K Gefunden: " << result;