0
How we solve this problem? (Help )
Enter a number to search:12 Found Enter a number to search:11 Not found Program: #include <stdio.h> int main() { âint a[10]; âint k; âfor (int i = 0; i < 10; i++) ââa[i] = i*2; â âfor (int j = 0; j < 10; j++) ââprintf("a[%d]= %d\n", j, a[j]); âprintf("Enter a number to search\n"); âscanf_s("%d", &k); âfor (int x = 0; x < 10; x++) â{ ââif (k == a[x]) âââprintf("Found"); ââelse âââprintf("Not found"); â} âreturn 0; }
3 RĂ©ponses
+ 4
Looks like you used a word processor to code or copy pasted this code from somewhere.
Because there are a lot of non printable characters in your code which were added by word processor to format it
0
You can solve it with linear or binary search... If you found the desired number, print found, break the loop, if it's not found (usually -1), print not found.