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 / sharan
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i;
int ele,temp=0;
clrscr();
printf("enter the array elements\n");
for (i=0; i<5; i++)
scanf("%d",&a[i]);
printf("Enter the element to be search\n");
scanf("%d",&ele);
// searching for the element
// searching for the element
for (i=0; i<5; i++)
{
if (a[i]==ele)
{
temp=1;
printf("Element found %d , position=%d\n",ele,i);
}
}
if (!temp)
printf("Element not found\n");
} // end of main()
| Is This Answer Correct ? | 149 Yes | 97 No |
Post New Answer View All Answers
ATM machine and railway reservation class/object diagram
What does s c mean on snapchat?
main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above
How would you use the functions fseek(), freed(), fwrite() and ftell()?
What does c mean in standard form?
What are the advantages of the functions?
int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above
write a program which the o/p should b in such a way that s triangle if I/p is 3,a Square/rectangle if I/P=4,a pentagon if I/P=5 and so on...forget about the I/P which is less than 3
What is the purpose of realloc()?
Can a function argument have default value?
What is typedef?
What are the functions to open and close the file in c language?
What is the return type of sizeof?
a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list
Is it better to use a macro or a function?