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
What is data structure in c language?
What's the right way to use errno?
Explain what is the benefit of using an enum rather than a #define constant?
code for quick sort?
Which is better pointer or array?
What does volatile do?
In C, What is the #line used for?
Is c procedural or object oriented?
What is build process in c?
How we can insert comments in a c program?
What is the difference between %d and %i?
Distinguish between actual and formal arguments.
Does sprintf put null character?
What is the use of a static variable in c?
What are the applications of c language?