diff --git a/Searching/LinearSearch.cpp b/Searching/LinearSearch.cpp new file mode 100644 index 0000000..309a115 --- /dev/null +++ b/Searching/LinearSearch.cpp @@ -0,0 +1,33 @@ +#include + +void main() +{ + int arr[10], i, num, n, c=0, pos; + cout<<"Enter the array size : "; + cin>>n; + cout<<"Enter Array Elements : "; + for(i=0; i>arr[i]; + } + cout<<"Enter the number to be searched: "; + cin>>num; + for(i=0; i +using namespace std; +void bubbleSort(int arr[], int n) { + for (int i = 0; i < n - 1; i++) { + if (arr[i] > arr[i + 1]) { + int temp = arr[i]; + arr[i] = arr[i+1]; + arr[i+1] = temp; + } + } + if (n - 1 > 1) { + bubbleSort(arr, n - 1); + } +} +int main() { + int arr[] = { 5,4,2,1,3 }; + int n = 5; + bubbleSort(arr, n); + for (int i = 0; i < n; i++) { + cout<< arr[i]<<"\t"; + } + return 0; +}