Posts

Search

Special Agent

QUESTION DESCRIPTION

A special agent is usually the title for a detective or investigator for a state, county, municipal, federal or tribal government who conducts criminal investigations and has arrest authority.

An agent is a federal law enforcement officer with arrest authority but who does not conduct major criminal investigations or who may conduct investigations but does not have arrest authority. Special agents are distinctly able to do both.

Special agents are often involved in breaking secret ciphers. In this problem we'll consider one of the challenges that agents usually face while decrypting secret messages.Now Find the element in sequence allocation scheme

TEST CASE 1

INPUT

5
56
87
54
34
62
87
OUTPUT
87 is present at location 2

TEST CASE 2

INPUT

6
5600
87
541
3421
541
43
13
OUTPUT
13 is not present in array

Code : 

#include <iostream>
using namespace std;
int main() {
  int a,b,j=0;
  int ar[a];
  cin>>a;
  for(int i=0;i<a;i++)
  {
    cin>>ar[i];
  }
  cin>>b;
    for(int i=0;i<a+1;i++)
  {
    if(ar[i]==b)
    {
      cout<<b<<" is present at location "<<i+1<<"\n";
      j=j+1;
    }
    }
  if(j==0)
  {
    cout<<b<<" is not present in array ";
  }
  
 return 0;
   
}