Write and test a C main program that a declare an array arr
Write and test a C++ main program that:
a. declare an array arr of 6 integers
b. Prompt the user for 6 integer values and store them in arr.
c. Prompt the user for a target integer target.
d. Search for target in arr. If target is found to match an element in the arr, then the program prints out a message which contains the address of the found element, otherwise, if no element found then the message “the element target not found” will be printed out. The program must use the array name-offset notation to traverse the array.
Write and test a C++ main program that:
a. declare an array arr of 6 integers
b. Prompt the user for 6 integer values and store them in arr.
c. Prompt the user for a target integer target.
d. Search for target in arr. If target is found to match an element in the arr, then the program prints out a message which contains the address of the found element, otherwise, if no element found then the message “the element target not found” will be printed out. The program must use the array name-offset notation to traverse the array.
1. Write and test a C++ main program that a. declare an array arr of 6 integers b. Prompt the user for 6 integer values and store them in arr. c. Prompt the user for a target integer target. d. Search for target in arr. If target is found to match an element in the arr, then the program prints out a message which contains the address of the found element, otherwise, if no element found then the message \"the element target not found\" will be printed out. The program must use the array name-offset notation to traverse the array. Solution
#include <iostream>
using namespace std;
int main(){
//Integer array of size 6
int arr[6];
int target;
//Input Array
cout<<\"Enter array elements\ \";
for(int i=0;i<6;i++){
cin>>arr[i];
}
//Input target
cout<<\"Enter target integer\ \";
cin>>target;
//Boolean to check if target found
bool targetFound = false;
int i=0;
while(*(arr+i)!=\'\\0\'){
if(*(arr+i)==target){
targetFound = true;
break;
}
i++;
}
if(targetFound){
//Printing address of the target
cout<<arr+i;
}
else{
//Target not found
cout<<\"The element target not found\";
}
return 0;
}

