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 / e v n raja

#include<stdio.h>
#include<conio.h>

void main()
{
int a[5],i,ele;


clrscr();

printf("enter the array elements
");

for (i=0; i<5; i++)
scanf("%d",&a[i]);

printf("Enter the element to be search
");
scanf("%d",&ele);

// searching for the element

for (i=0; i<5; i++)
{
if (a[i]==ele)
{
printf("Element found %d , position==%d",ele,i);
break;
}
}

} // end of main()

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers

1204


Why doesnt that code work?

1088


How can I find the modification date and time of a file?

1044


When should structures be passed by values or by references?

1004


Why main function is special give two reasons?

1498


Is c a great language, or what?

1062


Write a program to print fibonacci series without using recursion?

1076


When a c file is executed there are many files that are automatically opened what are they files?

1062


Difference between MAC vs. IP Addressing

1104


Can a pointer be volatile in c?

943


What does malloc () calloc () realloc () free () do?

1015


What is the difference between far and near ?

1161


What is a nested loop?

1083


What is variable and explain rules to declare variable in c?

1032


please give me some tips for the placement in the TCS.

2063