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 substring in c?
How can I recover the file name given an open stream?
What is 1f in c?
write a c program to calculate sum of digits till it reduces to a single digit using recursion
Calculate 1*2*3*____*n using recursive function??
What is %d used for?
What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?
What are the ways to a null pointer can use in c programming language?
1. Write a function to display the sum of two numbers in the following ways: By using (i) pass by value (ii) pass by address a. function with argument and with return value b. function with argument and without return value c. without argument , with return value d. without argument , without return value Note: Use pass by address.
What is array in C
write a program to find the given number is prime or not
how many key words availabel in c a) 28 b) 31 c) 32
FILE *fp1,*fp2; fp1=fopen("one","w") fp2=fopen("one","w") fputc('A',fp1) fputc('B',fp2) fclose(fp1) fclose(fp2)} a.error b. c. d.
Why dont c comments nest?
What is switch in c?