Bridges(File Allocation)

#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 ";
  }
   else
   {
	cout<<b<<" is present "<<j<<" times in array";
   }
	return 0;
   
}
//code by lakshay singhwal

Leave a comment

Design a site like this with WordPress.com
Get started