What Does The Following Code Dop Pre Langc Cssfilehk1style #1795
What does the following code do?</p> <pre><code class="language-c"> #include<stdio.h> int search_num(int *arr, int num, int len) { int i; for(i = 0; i < len; i++) if(arr[i] == num) return i; return -1; } int main() { int arr[5] ={1,2,3,4,5},num=3,len = 5; int indx = search_num(arr,num,len); printf("Index of %d is %d",num,indx); return 0; }</code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs122 Data Communication and Computer Network. It can also be found in gs gs122 Recursion - Search an Element in an Array using Recursion - Quiz No.1.
What does the following code do?
#include<stdio.h> int search_num(int *arr, int num, int len) { int i; for(i = 0; i < len; i++) if(arr[i] == num) return i; return -1; } int main() { int arr[5] ={1,2,3,4,5},num=3,len = 5; int indx = search_num(arr,num,len); printf("Index of %d is %d",num,indx); return 0; }
Search and returns the index of all the occurrences of the number that is searched
Search and returns the index of the first occurrence of the number that is searched
Search and returns of the last occurrence of the number that is searched
Returns the searched element from the given array
Similar question(s) are as followings:
Online Quizzes of gs122 Data Communication and Computer Network
Sorting - Insertion Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - Insertion Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - Insertion Sort - Quiz No.3
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - LSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - MSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - MSD Radix Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes