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
Here is a neat trick for checking whether two strings are equal
Explain b+ tree?
What are the properties of union in c?
What is a global variable in c?
Does * p ++ increment p or what it points to?
Can you please explain the difference between exit() and _exit() function?
application areas a 'c' a) operating system b) graphics, interpreter, assembler c) program evalution, communication softwares d) all the above
What is the difference between text files and binary files?
What is spaghetti programming?
Explain heap and queue.
Explain how are 16- and 32-bit numbers stored?
What are the different types of C instructions?
What are the types of c language?
What is break in c?
Why doesn't C support function overloading?