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 / mr. x

#include<stdio.h>
#include<conio.h>
void main ()
{
int a[5],b,c,i;
clrscr();
printf("
Enter no. of elements: ");
scanf("%d",&c);
i=0;
while(i<c)
{
scanf("%d",&a[i]);
i++;
}
printf("
Enter the elements to be searched: ");
scanf("%d",&b);
i=0;
while(i<c &b!=a[i])
{
i++;
}
if (i<c)
{
printf("number found");
i++;
}
else
{
printf(" number not found");
}
getch();
}

Is This Answer Correct ?    8 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Here is a neat trick for checking whether two strings are equal

1022


Explain b+ tree?

1077


What are the properties of union in c?

1055


What is a global variable in c?

1015


Does * p ++ increment p or what it points to?

1122


Can you please explain the difference between exit() and _exit() function?

1035


application areas a 'c' a) operating system b) graphics, interpreter, assembler c) program evalution, communication softwares d) all the above

1069


What is the difference between text files and binary files?

1352


What is spaghetti programming?

1143


Explain heap and queue.

1094


Explain how are 16- and 32-bit numbers stored?

1274


What are the different types of C instructions?

1320


What are the types of c language?

1038


What is break in c?

1051


Why doesn't C support function overloading?

2781