Skip to content

added linear search #22

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

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 2 additions & 0 deletions Frontend/index.html
Original file line number Diff line number Diff line change
@@ -4,9 +4,11 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Center</title>
</head>
<body>
<div class="krishnam">Krishnam Maheshwari</div>
<div class="box">center</div>
</body>
</html>
7 changes: 7 additions & 0 deletions Frontend/style.css
Original file line number Diff line number Diff line change
@@ -12,4 +12,11 @@ body {
.box {
height: 20rem;
width: 20rem;
}
.krishnam{
background-color: yellowgreen;
border-radius: 10px;
padding: 0.5rem 1rem;
margin: 2rem;
width: fit-content;
}
26 changes: 23 additions & 3 deletions linear-search.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
#include <stdio.h>
void display()
void display(int arr[])
{
// display code goes here
for(int i=0;i<9;i++)
{
printf("%d ",arr[i]);
}
}
int linearSearch()
int linearSearch(int arr[])
{
// linear search code goes here
int n,i;
printf("Enter the number want to linear search");
scanf("%d",&n);
for( i=0;i<9;i++)
{
if(arr[i]==n)
{
printf("YES");
break;
}
}
if(i==9)
{
printf("NO");
}
}
int main()
{
int arr[] = {5, 3, 7, 9, 10, 12, 7, 2, 4};
// main program

display(arr);
linearSearch(arr);
return 0;
}