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
- #include <stdio.h>
- intmain()
- {
- intarray[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);
- printf(“Enter a number to search\n“);
- scanf(“%d”, &search);
- for (c = 0; c < n; c++)
- {
- if (array == 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;
- }
program output