1.
/*WAP in C to take user input into array and print the elements from array*/
#include<stdio.h>
int main()
{
int arr[10],i,n;
printf("\n enter the size of an array:");
scanf("%d",&n);
//loop for take user input from keyboard
for(i=0;i<=n-1;i++)
scanf("%d",&arr[i]);
//loop for display value of the array
for(i=0;i<=n-1;i++)
printf("%d\t",arr[i]);
return 0;
2. /*WAP in C to search item using Linear search */
#include<stdio.h>
int main()
{
int arr[10],i,n,search,flag=0;
printf("\n enter the size of an array:");
scanf("%d",&n);
//loop for take user input from keyboard
for(i=0;i<=n-1;i++)
scanf("%d",&arr[i]);
//loop for display value of the array
for(i=0;i<=n-1;i++)
printf("%d\t",arr[i]);
printf("\n enter the Search item:");
scanf("%d",&search);
for(i=0;i<=n-1;i++)
{
if(search==arr[i])
{
flag=1;
break;
}
}
if(flag==1)
printf("%d is found at location %d into the array",search,i);
else
printf("%d is not found into the array",search);
return 0;
3. /*WAP in C to sort elements using Bubble sort technique*/
#include<stdio.h>
int main()
{
int arr[10],i,n,temp,j;
printf("\n enter the size of an array:");
scanf("%d",&n);
//loop for take user input from keyboard
for(i=0;i<=n-1;i++)
scanf("%d",&arr[i]);
//loop for display value of the array
printf("\n Before sorted :");
for(i=0;i<=n-1;i++)
printf("%d\t",arr[i]);
// sort elements using bubble sort
for(i=0;i<n-1;i++)
{
for(j=0;j<(n-i-1);j++)
{
if(arr[j]>arr[j+1])
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
printf("\n After sorted :");
for(i=0;i<=n-1;i++)
printf("%d\t",arr[i]);
return 0;