Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main (){
- int count=0;
- int i,size;
- int key;
- int a[100];
- printf("Enter the size of the array");
- scanf("%d",&size);
- printf("Enter the Elements :");
- for(i=0;i<size;i++){
- scanf("\n %d",&a[i]);
- }
- printf("Enter the Element You Want To Search ");
- scanf("%d",&key);
- for(i=0;i<size;i++){
- if(a[i] == key) {
- printf("%d is present at location %d \n",key , i+1);
- count++;
- }
- }
- if( count==0){
- printf("Element Not Found !");
- }
- else{
- printf("%d is present %d times in a array \n",key,count);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement