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

Is this program statement valid? INT = 10.50;

1105


Why does notstrcat(string, "!");Work?

1101


Explain what is #line used for?

1022


what do you mean by inline function in C?

1023


Explain how do you convert strings to numbers in c?

1039


how to print the character with maximum occurence and print that number of occurence too in a string given ?

2419


What are the advantages of using linked list for tree construction?

1042


Can you apply link and association interchangeably?

1083


how can I convert a string to a number?

1045


What are extern variables in c?

961


What are the parts of c program?

1059


What is switch in c?

1051


What is keyword in c?

973


Explain the red-black trees?

1081


What is the difference between NULL and NUL?

1258