Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a program to search for an element in a given array.
If the array was found then display its position otherwise
display appropriate message in c language

Answer Posted / aishwarya rajan

#include<iostream.h>
#include<conio.h>
void main()
{
int i,n,a[30];
char item;
cout<<"Enter the number of elements you would like to enter in the array: ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"Enter the element"<<i+1<<" :";
cin>>a[i];
}
cout<<"Enter the element you are searching for in the array:";
cin>>item;
if(a[i]==item)
cout<<"The item does exist in the array!! it is the "<<i+1<<" element!!";
else
cout<<"The item is not found in the array!!";
getch();
}

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2

1960


Who is the main contributor in designing the c language after dennis ritchie?

967


What is 1d array in c?

1049


What are the advantages of using linked list for tree construction?

1045


Can you define which header file to include at compile time?

996


What does c mean in standard form?

1134


What is the difference between char array and char pointer?

1006


I have seen function declarations that look like this

1009


What does emoji p mean?

1064


difference between native and cross compilers

2095


What is the importance of c in your views?

1127


What is the meaning of && in c?

980


What is the difference between ā€˜g’ and ā€œgā€ in C?

3948


What is the difference between scanf and fscanf?

1220


How can I recover the file name given an open stream?

976