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 / ghost
#include<stdio.h>
#include<conio.h>
void main()
{
int a[100],i,element,temp,pos;
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",&element);
// searching for the element
for (i=0; i<5; i++)
{
if (a[i]==element)
{
temp=1;
pos=++i;
}
}
if (temp==1)
printf("%d Element found at position==%d",element,pos);
else
printf("Element not found\n");
getch();
} // end of main()
| Is This Answer Correct ? | 13 Yes | 12 No |
Post New Answer View All Answers
Tell us something about keyword 'auto'.
What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?
What is typedf?
a=10;b= 5;c=3;d=3; if(a printf(%d %d %d %d a,b,c,d) else printf("%d %d %d %d a,b,c,d);
What is the advantage of c?
What is structure in c explain with example?
What is modifier & how many types of modifiers available in c?
Write a program to check prime number in c programming?
State two uses of pointers in C?
Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?
What are unions in c?
What does s c mean in text?
What are the 3 types of structures?
What are the advantages and disadvantages of pointers?
Do you know pointer in c?