1.
#include <stdio.h>
int main()
int n,a[10],sno,flag=0,count=0;
printf("Enter the no of elements of array ");
scanf("%d",&n);
printf("enter the elements of array ");
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
printf("enter the element to search ");
scanf("%d",&sno);
for(int i=0;i<n;i++){
count+=1;
if(a[i]==sno){
flag=1;
break;
if(flag==1){
printf("%d is found\n",sno);
printf("%d is no of steps",count);}
else{
printf("%d is not found\n",sno);
printf("%d is no of steps",count);
}
return 0;
2.
#include <stdio.h>
#include<time.h>
int main()
clock_t start,end;
int n,a[10],sno,flag=0,count=0;
double total=0;
start=clock();
printf("Enter the no of elements of array ");
scanf("%d",&n);
printf("enter the elements of array ");
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
printf("enter the element to search ");
scanf("%d",&sno);
for(int i=0;i<n;i++){
count+=1;
if(a[i]==sno){
flag=1;
break;
end=clock();
total=(double)(end-start)/CLOCKS_PER_SEC;
if(flag==1){
printf("%d is found\n",sno);
printf("%d is no of steps\n",count);}
else{
printf("%d is not found\n",sno);
printf("%d is no of steps\n",count);
printf("total time taken by the cpu:%f",total);
return 0;