#### C Programming

- Print integer
- Add & subtract
- Odd & even
- Multiply & divide
- Check vowels
- Letter grade program
- Leap year program
- Sum of digits
- Prime numbers
- Sum of numbers
- Find factorial
- Fibonacci series
- Fibonacci triangle
- Number triangle
- Alphabet triangle
- Armstrong numbers
- Palindrome numbers
- Swap number
- Reverse number
- Decimal to binary
- Assembly code in C
- Matrix multiplication
- HCF & LCM
- nCr & nPr
- Print pattern
- Floyd’s triangle
- Pascal triangle
- Count digits
- Strong numbers
- Perfect numbers
- Sum of natural number
- Binary to decimal
- Decimal to octal
- Octal to decimal
- Binary to octal
- Octal to binary
- Add using pointer
- Bubble sort
- Insertion sort
- Selection sort
- Quick sort
- Binary search
- Linear search
- Largest element of array
- Smallest element of array
- Reverse Array
- Variable size & limit
- ASCII value of character
- Sum of array elements
- Number of element in array
- Merge two array
- Insert element in array
- Delete element from array
- Add two matrix
- Transpose matrix
- Print string
- Reverse string
- Delete vowels
- Sort string
- Remove spaces
- Swap string
- Random numbers
- Print date & time
- Print IP address
- Shut down computer

## Searching algorithm: linear search in C

## C program using linear search

```
// c program implementing linear search algorithm
#include <stdio.h>
int main(){
int a, Num, search, myarr[50];
printf("Enter number of elements of the array here : ");
scanf("%d", &Num);
printf("Enter %d integers as array element : \n", Num);
for(a = 0; a < Num; a++){
scanf("%d", &myarr[a]);
}
printf("Enter which number you want to search : ");
scanf("%d", &search);
for(a = 0; a < Num; a++){
if (myarr[a] == search){
printf("\nNumber (%d) is present at location %d.\n", search, a+1);
break;
}
}
if(a == Num){
printf("\n%d is not present here in the array.\n", search);
}
return 0;
}
```

### Output of this linear search program

## Linear search for multiple occurrence in C

```
// linear search algorithm in c for multiple matching
#include <stdio.h>
int main(){
int Num, myarr[50], sr, counter = 0, k;
printf("Enter number of integers in the array : ");
scanf("%d", &Num);
printf("\nEnter %d integers bellow : \n", Num);
for (k = 0; k < Num; k++){
scanf("%d", &myarr[k]);
}
printf("\nEnter which integer you want to search : ");
scanf("%d", &sr);
for (k = 0; k < Num; k++){
if (myarr[k] == sr){
printf("\n%d is found at location %d.\n", sr, k + 1);
counter++;
}
}
if (counter == 0){
printf("\n%d is not present here in given array.\n", sr);
}else{
printf("\n%d is found %d times in your given array.\n", sr, counter);
}
return 0;
}
```

### Program output will be as follows

```
Enter number of integers in the array : 10
Enter 10 integers bellow :
12 23 34 45 23 45 23 65 23 15
Enter which integer you want to search : 23
23 is found at location 2.
23 is found at location 5.
23 is found at location 7.
23 is found at location 9.
23 is found 4 times in your given array.
```

```
Enter number of integers in the array : 5
Enter 5 integers bellow :
100 200 400 300 50
Enter which integer you want to search : 700
700 is not present here in given array.
```

**Previous page**:Â **Binary search**

**Next page**:Â **Largest element in array**

**Recommended for you**: