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
Is there sort function in c?
Is null always equal to 0(zero)?
What is a pointer value and address in c?
How can I recover the file name given an open stream or file descriptor?
Can 'this' pointer by used in the constructor?
How can a program be made to print the name of a source file where an error occurs?
What are comments and how do you insert it in a C program?
How can you tell whether a program was compiled using c versus c++?
Write a program to print fibonacci series without using recursion?
Badboy is defined who has ALL the following properties: Does not have a girlfriend and is not married. He is not more than 23 years old. The middle name should be "Singh" The last name should have more than 4 characters. The character 'a' should appear in the last name at least two times. The name of one of his brothers should be "Ram" Write a method: boolean isBadBoy(boolean hasGirlFriend , boolean isMarried, int age , String middleName , String lastName , String[] brotherName); isHaveGirlFriend is true if the person has a girlfriend isMarried is true if the person is married age is the age of the person middleName is the middle name of the person lastName is the last name of the person brotherName is the array of the names of his brothers
What is exit() function?
What is difference between Structure and Unions?
What is the explanation for prototype function in c?
How many types of sorting are there in c?
Explain what are the standard predefined macros?