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 / anuja kulkarni

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

void main()
{
int a[5],i;
int ele,temp=0,pos=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

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

if (temp==1)
printf("Element found %d , position==%d",ele,pos);
else
printf("Element not found\n");
} // end of main()

Is This Answer Correct ?    483 Yes 132 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how could explain about job profile

1856


c program for searching a student details among 10 student details

2041


How are portions of a program disabled in demo versions?

1231


Explain heap and queue.

1010


Is boolean a datatype in c?

1011


Explain pointer. What are function pointers in C?

1016


Which of these functions is safer to use : fgets(), gets()? Why?

1044


Explain what is operator promotion?

1024


Difference between Shallow copy and Deep copy?

1968


When should a type cast not be used?

1004


What is structure padding in c?

1058


What is the difference between array and linked list in c?

1083


What does == mean in texting?

1212


What is malloc calloc and realloc in c?

1215


Explain the process of converting a Tree into a Binary Tree.

2607