Explain this code of linear search in hindi or english | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

Explain this code of linear search in hindi or english

#include <stdio.h> int main() {   int array[100], search, c, n;   printf("Enter number of elements in array\n");   scanf("%d", &n);   printf("Enter %d integer(s)\n", n);   for (c = 0; c < n; c++)     scanf("%d", &array[c]);   printf("Enter a number to search\n");   scanf("%d", &search);   for (c = 0; c < n; c++)   {     if (array[c] == search)    /* If required element is found */     {       printf("%d is present at location %d.\n", search, c+1);       break;     }   }   if (c == n)     printf("%d isn't present in the array.\n", search);   return 0; }

6th Sep 2022, 6:52 AM
Abhishek
Abhishek - avatar
4 Answers
+ 4
First learn the basics of C, then try to understand C code. https://www.sololearn.com/learn/661/?ref=app People are more likely to inspect your code if you put it on sololearn playground: Go to Code section, click +, select the programming language, insert your code, save. Come back to this thread, click +, Insert Code, sort for My Code Bits, select your code. This way it is more readable and people can test the code.
6th Sep 2022, 7:30 AM
Lisa
Lisa - avatar
+ 3
after passing this, you will understand. you havent even opened this course yet https://www.sololearn.com/Course/C/?ref=app
6th Sep 2022, 7:01 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
Hi! do you not understand the entire code or some part of it?
6th Sep 2022, 6:54 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
I don't understand
6th Sep 2022, 6:58 AM
Abhishek
Abhishek - avatar