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 / kapil hansrajani

include<stdio.h>
#include<conio.h>
void main()
{
int a[100],i,j,n;
clrscr();
printf("Enter the number of elements : ");
scanf("%d",&n);
printf("Enter the elements: ");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("Enter the element to search : ");
scanf("%d",&j);
for(i=0;i<n;i++)
{
if(a[i]==j)
{
printf("The position of the element %d is %d ",j,i);
break;
}
}
getch();
}

Is This Answer Correct ?    48 Yes 26 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I find out how much free space is available on disk?

1010


What do you mean by recursion in c?

1050


What are the advantages and disadvantages of a heap?

1145


What is difference between union All statement and Union?

1055


What are the main characteristics of c language describe the structure of ac program?

1144


An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above

1103


What does sizeof int return?

1022


Do you have any idea about the use of "auto" keyword?

1048


Can main () be called recursively?

1058


Write a program to check armstrong number in c?

1081


any limit on the number of functions that might be present in a C program a) max 35 functions b) max 50 functions c) no limit d) none of the above

980


Why void is used in c?

948


what is the height of tree if leaf node is at level 3. please explain

2084


How do you construct an increment statement or decrement statement in C?

1173


Compare interpreters and compilers.

1027