Dsalaab
Dsalaab
#include <stdio.h>
int main()
{
int arr[20]; // Array to hold up to 20 elements
int i, size, searchElement;
output
binary search
#include <stdio.h>
#include <conio.h> // Required for getch() in Turbo C++
int main() {
int n, search, found = 0;
int low, high, mid;
int a[20]; // Array to hold up to 20 elements
// Ensure the number of elements does not exceed the array size
if (n > 20 || n <= 0) {
printf("Invalid number of elements! Please enter a number between 1 and
20.\n");
getch(); // Wait for user input before exiting
return 1; // Exit with an error code
}
output
a[5] = 798
Enter the element to search: 87
Element found at position: 5
bubble sort
#include <stdio.h>
#include <conio.h>
int main() {
int n, i, j, temp, a[100];
output
Enter the total integers you want to enter (make it less than 100):
5
Enter the 5 integer array elements:
34
12
5
78
23
The sorted numbers are: 5 12 23 34 78
quick sort
#include <stdio.h>
#include <conio.h>
int main() {
int arr[30]; // Array to hold up to 30 elements
int size;
// Prompt user for the total number of elements
printf("Enter total number of elements (up to 30): ");
scanf("%d", &size);
output