Skip to content
Open
Show file tree
Hide file tree
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
35 changes: 35 additions & 0 deletions Bubblesort.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <iostream>

using namespace std;

int main()
{ int n=0,i=0,max=0;
cout<<"\t\tProgram on Bubble sort";
cout<<"\nEnter the size of array : ";cin>>n;
int a[n];
cout<<"Enter the array elements :\n";
for(i=0;i<n;i++)
{cin>>a[i];}
int j=0;
max=0;
for(i=0;i<n;i++)
{
{
for(j=0;j<n-i-1;j++)
{if(a[j]>a[j+1])
{
max=a[j];
a[j]=a[j+1];
a[j+1]=max;
}}
}

}
cout<<"Sorted Element are :";
for(i=0;i<n;i++)
{cout<<a[i];}

return 0;
}


29 changes: 29 additions & 0 deletions linearsearch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <iostream>

using namespace std;

int main()
{ int n=0,i=0,num=0,max=0,pos=0;
cout<<"\t\tProgram on Linear Search";
cout<<"\nEnter the size of array : ";cin>>n;
int a[n];
cout<<"Enter the array elements :\n";
for(i=0;i<n;i++)
{cin>>a[i];}
cout<<"Enter the search elemnet :";cin>>num;
max=0;
for(i=0;i<n;i++)
{
if(a[i]==num)
{
max=a[i];;
pos=i+1;
}

}
cout<<"Element :"<<max<<"\nfound at position :"<<pos;

return 0;
}