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

What is the use of ?: Operator?

1185


How can I discover how many arguments a function was actually called with?

1113


Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.

2127


Which header file is essential for using strcmp function?

1533


What is the difference between array and structure in c?

1244


main() { printf("hello"); fork(); }

1248


What is variable declaration and definition in c?

967


When should a type cast be used?

1065


How many levels of pointers have?

1098


Explain about the constants which help in debugging?

1420


Difference between Shallow copy and Deep copy?

2075


Why is sizeof () an operator and not a function?

1089


In C language what is a 'dangling pointer'?

1241


How to write a multi-statement macro?

1100


What is a scope resolution operator in c?

1328