Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main (){
  4.  
  5. int count=0;
  6. int i,size;
  7. int key;
  8.  
  9. int a[100];
  10. printf("Enter the size of the array");
  11. scanf("%d",&size);
  12.  
  13. printf("Enter the Elements :");
  14. for(i=0;i<size;i++){
  15.  
  16. scanf("\n %d",&a[i]);
  17.  
  18. }
  19. printf("Enter the Element You Want To Search ");
  20. scanf("%d",&key);
  21.  
  22. for(i=0;i<size;i++){
  23. if(a[i] == key) {
  24. printf("%d is present at location %d \n",key , i+1);
  25. count++;
  26. }
  27.  
  28. }
  29. if( count==0){
  30. printf("Element Not Found !");
  31. }
  32. else{
  33. printf("%d is present %d times in a array \n",key,count);
  34.  
  35. }
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement