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

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

void main()
{
int a[5],i;
int ele,temp=0;

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",&ele);

// searching for the element

// searching for the element
for (i=0; i<5; i++)
{
if (a[i]==ele)
{
temp=1;
printf("Element found %d , position=%d\n",ele,i);
}
}
if (!temp)
printf("Element not found\n");
} // end of main()

Is This Answer Correct ?    149 Yes 97 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

ATM machine and railway reservation class/object diagram

5253


What does s c mean on snapchat?

1116


main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above

1103


How would you use the functions fseek(), freed(), fwrite() and ftell()?

1166


What does c mean in standard form?

1185


What are the advantages of the functions?

1164


int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above

1306


write a program which the o/p should b in such a way that s triangle if I/p is 3,a Square/rectangle if I/P=4,a pentagon if I/P=5 and so on...forget about the I/P which is less than 3

2082


What is the purpose of realloc()?

1148


Can a function argument have default value?

1157


What is typedef?

1431


What are the functions to open and close the file in c language?

1041


What is the return type of sizeof?

1067


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

1065


Is it better to use a macro or a function?

1165