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

Tell us something about keyword 'auto'.

1070


What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

1275


What is typedf?

1124


a=10;b= 5;c=3;d=3; if(a printf(%d %d %d %d a,b,c,d) else printf("%d %d %d %d a,b,c,d);

1128


What is the advantage of c?

1125


What is structure in c explain with example?

1159


What is modifier & how many types of modifiers available in c?

1026


Write a program to check prime number in c programming?

1088


State two uses of pointers in C?

1052


Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?

1250


What are unions in c?

1028


What does s c mean in text?

1095


What are the 3 types of structures?

1027


What are the advantages and disadvantages of pointers?

1070


Do you know pointer in c?

1044