Advertisement
ovi_salman

Problem No 20

Jul 29th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int a[100],key,n;
  7. cin>>n;
  8.  
  9. for(int i=0; i<n; i++)
  10. {
  11. cin>>a[i];
  12. }
  13. cout<<endl;
  14.  
  15.  
  16. for(int i=0; i<n; i++)
  17. {
  18. cout<<a[i]<<" ";
  19. }
  20. cout<<endl;
  21.  
  22. cin>>key;
  23. cout<<endl;
  24.  
  25. for(int i=0; i<n-1; i++)
  26. {
  27. if(a[i]==key){
  28. cout<<key<<" Found at index "<<i;
  29. }
  30. }
  31.  
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement