#include <iostream>
using namespace std;
int main(){
int LA[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
cout<<"Enter number to search for: ";
int p; cin>>p;
bool found = false;
for(int i = 0; i < 10; i++){
if(LA[i] == p){
cout<<"Found at location "<<i<<"\n";
found = true;
p = i;
break;
}
}
if(found){
cout<<"Square of the location: "<<p * p;
}
else cout<<"Element not found";
return 0;
}
Comments
Leave a comment