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 / mr. x
#include<stdio.h>
#include<conio.h>
void main ()
{
int a[5],b,c,i;
clrscr();
printf("
Enter no. of elements: ");
scanf("%d",&c);
i=0;
while(i<c)
{
scanf("%d",&a[i]);
i++;
}
printf("
Enter the elements to be searched: ");
scanf("%d",&b);
i=0;
while(i<c &b!=a[i])
{
i++;
}
if (i<c)
{
printf("number found");
i++;
}
else
{
printf(" number not found");
}
getch();
}
Is This Answer Correct ? | 8 Yes | 5 No |
Post New Answer View All Answers
What does stand for?
Can a function argument have default value?
What does char * * argv mean in c?
What is auto keyword in c?
What is union and structure in c?
any limit on the number of functions that might be present in a C program a) max 35 functions b) max 50 functions c) no limit d) none of the above
Why string is used in c?
What type is sizeof?
Why should I use standard library functions instead of writing my own?
Can you please compare array with pointer?
What is preprocessor with example?
How can you pass an array to a function by value?
What is the need of structure in c?
How are structure passing and returning implemented?
write a program to print data of 5 five students with structures?