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
What is pointers in c?
List a few unconditional control statement in c.
Is sizeof a keyword in c?
What is cohesion and coupling in c?
Is null valid for pointers to functions?
we need to calculating INCOME TAX for the person. The INCOME TAX is as follows:- First $10000/- of income : 4% tax Next $10000/- of income : 8% tax Next $10000/- of income : 11.5% tax above $10, 00,00/- : 15% tax What is the Solution of this Question ?
Explain what is a const pointer?
Why c is called top down?
Is there any possibility to create customized header file with c programming language?
What is calloc()?
what is the structure pointer?
What type is sizeof?
What is the code for 3 questions and answer check in VisualBasic.Net?
What is the difference between char array and char pointer?
Is c is a low level language?