Skip to content

Update exercise3.c #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions exercise3.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//documentation section
/* Exercise 3 - Sequential Search - Sorted List*/
/* Exercise 2*/

//pre-processor section
#include<stdio.h>
Expand All @@ -10,8 +10,48 @@
//main function section
int main(){
//write here your program
int n,a,i,count=0;
printf("Enter the number of elements in the array:\n");
scanf("%d",&n);
int array[n];
printf("Enter the numbers in the array:\n");
for(i=0; i<n ;i++)
scanf("%d",&array[i]);
printf("Enter the number to be searched: ");
scanf("%d",&a);

for(i=0; i<n ;i++){
printf("LA[%d] = %d \n", i, LA[i]);
}
j = k;

while(j<n){
LA[j-1] = LA[j];
j = j + 1;
}

n = n - 1;

printf("The array elements after deletion : \n");

for(i=0; i<n; i++){
printf("LA[%d] = %d \n", i, LA[i]);
}


if(array[i]==a)
{
printf("Element with value %d is present in arr[]\n",a,i);
count++;
}

if(count==0)
printf("Element with value %d is not present in arr[]\n",a);
else
printf("Element with value %d is present at index %d",a,i);
return 0;


}

//user-defined section
//user-defined section