Created
January 10, 2022 07:01
-
-
Save Dbhardwaj99/6a17b02b706e4602143a641391a8f520 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int i,l; | |
int search(int ,int *,int); | |
int main(){ | |
int n,m; | |
printf("enter the size of array:"); | |
scanf("%d",&n); | |
int a[n]; | |
printf("enter the elements:\n"); | |
for(i=0;i<n;i++){ | |
scanf("%d",&a[i]); | |
} | |
printf("enter the element to be searched:"); | |
scanf("%d",&m); | |
search(n,a,m); | |
return 0; | |
} | |
int search(int n,int *a,int m){ | |
for(i=0;i<n;i++){ | |
if(m==a[i]){ | |
l=1; | |
break; | |
} | |
} | |
if(l==1){ | |
printf("%d is present in the array",m); | |
} else { | |
printf("%d is not present in the array",m); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#include<stdio.h>
int i,l;
int main(){
int n,m;
printf("enter the size of array:");
scanf("%d",&n);
int a[n];
int *p = a;
printf("enter the elements:\n");
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
printf("enter the element to be searched:");
scanf("%d",&m);
for(i=0;i<n;i++){
if(p[i]==m){
l=1;
break;
}
}
if(l==1){
printf("%d is present in the array",m);
} else {
printf("%d is not present in the array",m);
}
return 0;
}