what is linear array with Example in Hindi ? लिनियर अर्रे क्या है

what is linear array with Example ? लिनियर अर्रे क्या है

Linear Arrays in c

हमने  आपको linear array को हिन्दी ओर English दोनों language (भाषा ) मे समझाया है । साथ मे एक example program भी दिया है

what is Linear Arrays in English

Linear search in C programming: The following code implements linear search (Searching algorithm) which is used to find whether a given number is present in an array and if it is present then at what location it occurs. It is also known as a sequential search. It is straightforward and works as follows: We keep on comparing each element with the element to search until it is found or the list ends. Linear search in C language for multiple occurrences and using function.

 

what is Linear Arrays in c in Hindi

Array एक ऐसा Data Structure होता है जिसमें एक ही Data Type के n Data Items, एक list के रूप  मे  store हो सकते है जबकि n Array की size को define करता है यदि किसी array की size n हो  व  n का मान 10 हो तो उस array मै हम केवल दस data item store करके रख सकते है

 

array के हर item को index number से access किया जाता है किसी array का प्रथम item हमेशा index number 0 पर store होता है ओर array का अंतिम item हमेशा index number n-1 पर स्टोर होता है किसी array के index number 0 को array का lower bound ओर index number n-1 को array का upper bound कहते है किसी array की length या size को हम निम्न सूत्र द्वारा प्राप्त कर सकते है

SIZE = UB + 1

जहां

UB = Upper Bound

LB = Lower Bound

हम किसी भी  Index Number को हमेशा bracket []के बीच मे लिखते है जेसे यदि किसी  Array के  Index Number 4 के  Data Item को  Access करना हो तो हम  Array[4] लिखते है

Example

Linear search C program

  1. #include <stdio.h>
  2. intmain()
  3. {
  4. intarray[100], search, c, n;
  5. printf(“Enter number of elements in array\n“);
  6. scanf(“%d”,&n);
  7. printf(“Enter %d integer(s)\n“, n);
  8. for (c = 0; c < n; c++)
  9.   scanf(“%d”, &array);
  10. printf(“Enter a number to search\n“);
  11. scanf(“%d”, &search);
  12. for (c = 0; c < n; c++)
  13. {
  14.   if (array == search)    /* If required element is found */
  15.   {
  16.     printf(“%d is present at location %d.\n“, search, c+1);
  17.     break;
  18.   }
  19. }
  20. if (c == n)
  21.   printf(“%d isn’t present in the array.\n“, search);
  22. return 0;
  23. }

program output

output of liner array
output of liner array

 

Leave a Comment