Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

#include <iostream>

using namespace std;

int main(){
int x;

int a[10];
for(int i=0;i<10;i++){
cin>>a[i];
}
cin>>x;
int count=0;
for(int j=0;j<10;j++){
if(a[j]==x){
count=j+1;
break;
}
}
if(count==0){
cout<<"ELEMENT NOT FOUND";
}
else{
cout<<count;
}

return 0;
}

#include <iostream>

using namespace std;

int main(){
int input[10], i, x;
int count=0;
cout << "Enter Number of Elements in Array\n";
cin >> count;

cout << "Enter " << count << " numbers \n";

for(i = 0; i < 10; i++){


cin >> input[i];
}

cout << "Enter a number to serach in Array\n";


cin >> x;

for(i = 0; i < 10; i++){


if(input[i] == x){
count=i+1;
cout << count;
break;
}
}

if(i == count){
cout << "Element Not foud\n";
}

return 0;
}

You might also like