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 / ghost

#include<stdio.h>
#include<conio.h>

void main()
{
int a[100],i,element,temp,pos;

clrscr();
printf("enter the array elements\n");
for (i=0; i<5; i++)
scanf("%d",&a[i]);
printf("Enter the element to be search\n");
scanf("%d",&element);

// searching for the element

for (i=0; i<5; i++)
{
if (a[i]==element)
{
temp=1;
pos=++i;
}
}

if (temp==1)
printf("%d Element found at position==%d",element,pos);
else
printf("Element not found\n");
getch();

} // end of main()

Is This Answer Correct ?    13 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is wrong with this statement? Myname = ?robin?;

1588


How are pointers declared in c?

1062


write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list

2808


What are loops in c?

1008


What is the difference between the expression “++a” and “a++”?

1234


a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list

1064


How can I avoid the abort, retry, fail messages?

1138


What is structure in c explain with example?

1164


All technical questions

1992


How do you redirect a standard stream?

1110


What is hungarian notation? Is it worthwhile?

1225


Describe explain how arrays can be passed to a user defined function

1105


What is dangling pointer in c?

1238


What are header files in c?

1080


What is a pointer on a pointer in c programming language?

1141