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

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

int main()
{
int a[20],i,temp=0,n,pos=0,element;
//clrscr();
printf("Search an Element in Array\n");
printf("Enter the number of elements: ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter the value for elements: ");
scanf("%d",&a[i]);
}
printf("Enter the searching element: ");
scanf("%d",&element);
for(i=0;i<n;i++)
{
if(a[i]==element)
{
temp=1;
pos=i;
}
}
if (temp==1)
printf("Element found %d , position=%
d",element,pos);
else
printf("Element not found\n");
getch();
}

Is This Answer Correct ?    56 Yes 31 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does %c mean in c?

1100


What is the purpose of main( ) in c language?

1142


What's the difference between constant char *p and char * constant p?

1153


How is a pointer variable declared?

1102


In which layer of the network datastructure format change is done

1891


Explain what does the format %10.2 mean when included in a printf statement?

1367


exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above

1128


Explain how can I pad a string to a known length?

1198


What is the size of enum in bytes?

1091


"%u" unsigned integer print the a) address of variable b) value of variable c) name of a variable d) none of the above

1026


why do some people write if(0 == x) instead of if(x == 0)?

1083


what is the structure pointer?

2131


Explain what is the difference between null and nul?

1161


What is the c language function prototype?

1088


Is there any demerits of using pointer?

1075