wite a programme in c to linear search a data using flag and
without using flags?
Answer Posted / ruchi
#include<stdio.h>
#include<conio.h>
int main()
{
int n,i,a[15],num;
printf("\nHow many elements are there ");
scanf("%d",&n);
printf("\nEnter the elements ");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\nEnter the element do you want to search ");
scanf("%d",&num);
for(i=0;i<n;i++)
{
if(a[i]==num)
{
printf("\nElement is present ");
break;
}
else if((a[i]!=num)&&(i==n-1
))
{
printf("\nElement is not present");
}
}
getch();
}
| Is This Answer Correct ? | 19 Yes | 8 No |
Post New Answer View All Answers
Why is a semicolon (;) put at the end of every program statement?
Describe how arrays can be passed to a user defined function
What are different storage class specifiers in c?
How can I find out the size of a file, prior to reading it in?
What is the c value paradox and how is it explained?
How to explain the final year project as a fresher please answer with sample project
Can a local variable be volatile in c?
What is the purpose of the statement: strcat (S2, S1)?
Why is structure important for a child?
What is multidimensional arrays
Difference between constant pointer and pointer to a constant.
show how link list can be used to repersent the following polynomial i) 5x+2
What are 3 types of structures?
Can we replace the struct function in tree syntax with a union?
What is the sizeof () a pointer?