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 main function is called in c?

1132


How can I do graphics in c?

1038


What does sizeof int return?

1085


Explain what are the standard predefined macros?

1122


How can I determine whether a machines byte order is big-endian or little-endian?

1067


What is the use of a conditional inclusion statement in C?

1070


What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

1251


What is c language & why it is used?

1116


What is the difference between variable declaration and variable definition in c?

1065


What is meant by realloc()?

1164


Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?

2549


How can a string be converted to a number?

1023


What is the purpose of 'register' keyword?

1103


What are the features of c languages?

1107


Between macros and functions,which is better to use and why?

2230