+ 2

Array

How we find the index of array?

3rd Feb 2025, 5:00 AM
Sankar Zaya
Sankar Zaya - avatar
11 Answers
+ 8
Sankar Zaya , it would be helpful if you could give some more details. please give a brief description what you are going to achieve with your code. if you have done a try so far, please post it here.
3rd Feb 2025, 7:31 AM
Lothar
Lothar - avatar
+ 5
Guys sry I had an issue on my side ... can't explain but corrected .. Thanks 👍 for flagging Bob_Li Zvi
3rd Feb 2025, 2:48 PM
BroFar
BroFar - avatar
M
+ 4
BroFar it's tagged 'c'...🤣
3rd Feb 2025, 9:50 AM
Bob_Li
Bob_Li - avatar
+ 3
Sankar Zaya something like this .... #include <stdio.h> int main() { int arr[] = {10, 20, 30, 40, 50}; int size = sizeof(arr) / sizeof(arr[0]); int target = 30; for (int j = 0; j < size; j++){ if (arr[j] == target){ printf("%d ",j); // index of target break; } } return 0; }
3rd Feb 2025, 7:19 AM
BroFar
BroFar - avatar
M
+ 3
BroFar why would you do it that way over let arr=[10,20,30,40]; let index= arr.indexOf(30); console.log(index) Or does your way also work for c while mine in only Javascript? Because what you did doesn’t look to me like c, although I really don’t know much about c, but it does look like javascript.
3rd Feb 2025, 1:57 PM
Zvi
Zvi - avatar
+ 2
Chilka Mariyadasu please do not spam the threads of the question and answer forum by posting multiple comments without reading prior responses as this question was answered.
4th Feb 2025, 6:52 PM
BroFar
BroFar - avatar
M
0
Hmmm
3rd Feb 2025, 7:41 PM
Baraa
Baraa - avatar
0
Hi guys
4th Feb 2025, 2:47 AM
Israel
0
Madame reply message
4th Feb 2025, 6:44 PM
Chilka Mariyadasu
Chilka Mariyadasu - avatar
0
Madame amount please conditionlanu
4th Feb 2025, 6:45 PM
Chilka Mariyadasu
Chilka Mariyadasu - avatar
0
Amount NEEFT to 1 rupees please find the condition
4th Feb 2025, 6:46 PM
Chilka Mariyadasu
Chilka Mariyadasu - avatar