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

Explain the difference between malloc() and calloc() in c?

1013


What is LINKED LIST? How can you access the last element in a linked list?

1033


What are unions in c?

991


Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor

3485


Explain how do you list files in a directory?

1028


What is the maximum no. of arguments that can be given in a command line in C.?

1101


Explain what is a pragma?

1007


what are non standard function in c

1864


Compare interpreters and compilers.

1037


Is there a way to jump out of a function or functions?

1046


Write a function expand(s1,s2) that expands shorthand notations like a-z in the string s1 into the equivalent complete list abc...xyz in s2 . Allow for letters of either case and digits, and be prepared to handle cases like a-b-c and a-z0-9 and -a-z. z-a:zyx......ba -1-6-:-123456- 1-9-1:123456789987654321 a-R-L:a-R...L a-b-c:abbc

5572


Explain what are the standard predefined macros?

1085


Differentiate between the = symbol and == symbol?

1226


Explain what is the best way to comment out a section of code that contains comments?

1103


When can a far pointer be used?

978