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


Please Help Members By Posting Answers For Below Questions

The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none

753


Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?

569


What is the use of pointers in C?

605


what is the difference between class and unio?

1850


What is c programming structure?

612






Why is c called a structured programming language?

662


What is the use of putchar function?

642


Explain how can you check to see whether a symbol is defined?

648


What is NULL pointer?

668


What is far pointer in c?

797


can any one tel me wt is the question pattern for NIC exam

1549


How do you determine a file’s attributes?

589


What is data structure in c programming?

561


Describe the order of precedence with regards to operators in C.

626


regarding pointers concept

1561