Computer Science, asked by mountainzzakir, 11 months ago

write a program to find the position of a given element in an array of 1st PUC computer science ​

Answers

Answered by guru5774
2

Answer:

#include<iostream.h>

#include<condo.h>

#include<iomanip.h>

void main()

{

int a[50],i,pos,ele,n;

clrscr();

cout<<"enter the number"<<endl;

cin>>n;

cout<<"enter the elements";

for(i=0;i<n;i++)

cin>>a[i];

cout<<"enter the search elements";

cin>>ele;

pos=-1;

for(i=0;i<n;i++)

if(ele==a[i])

{

pos=i;

break;

}

if(pos>=0)

cout<<"the elements"<<ele<<"is present at position"<<pos<<endl;

else

cout<<"the search elements"<<ele<<"is not present"<<endl;

getch();

}

Similar questions