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 / poorni
#include<stdio.h>
#include<conio.h>
int main()
{
int a[20],i,temp=0,n,pos=0,element;
//clrscr();
printf("Search an Element in Array\n");
printf("Enter the number of elements: ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter the value for elements: ");
scanf("%d",&a[i]);
}
printf("Enter the searching element: ");
scanf("%d",&element);
for(i=0;i<n;i++)
{
if(a[i]==element)
{
temp=1;
pos=i;
}
}
if (temp==1)
printf("Element found %d , position=%
d",element,pos);
else
printf("Element not found\n");
getch();
}
| Is This Answer Correct ? | 56 Yes | 31 No |
Post New Answer View All Answers
When should the register modifier be used? Does it really help?
What does c mean in basketball?
Define Spanning-Tree Protocol (STP)
Does c have circular shift operators?
What is struct node in c?
In C language, a variable name cannot contain?
What are high level languages like C and FORTRAN also known as?
What is pointer to pointer in c language?
Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.
What is an auto keyword in c?
What are the basic data types associated with c?
Explain how do you list a file’s date and time?
What is conio h in c?
Study the following C program :call_me (myvar)int myvar;{ myvar +- 5; }main(){int myvar;myvar = 3;call_me(myvar);printf("%d ",myvar);What will be printed a) 3 b) 5 c) 8 d) symbol
Why do we use static in c?