SEP- ADA

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7

PART B

PROGRAM B1 PROGRAM B2 PROGRAM B3 PROGRAM B4 PROGRAM B5 PROGRAM B6 PROGRAM B7 . . .

 
   
1. Write a program to find an element using Sequential Search.
// Algorithm: SequentialSearch
// Input: A: The array to search, N: Size of the array, key: The value to find
// Output: A list of indices where 'key' is found or -1 if 'key' is not present.
Step 1: Read N, array A, and key.
Step 2: found ← 0
Step 3: For i ← 0 to N − 1 do
Step 4: If A[i] = key then
Step 5: Print i
Step 6: found ← 1
Step 7: If found = 0 then
Step 8: Print "Element not found"
#include
void main()
{
int a[100], n, key, i, found = 0;
printf("Enter array size: ");
scanf("%d", &n);
printf("Enter array elements: ");
for(i=0; i