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 an lvalue?
write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);
i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical
Explain how can you tell whether a program was compiled using c versus c++?
What is function prototype in c with example?
What is c language & why it is used?
What is a program flowchart and how does it help in writing a program?
What is self-referential structure in c programming?
How can I get the current date or time of day in a c program?
What is the main difference between calloc () and malloc ()?
What is the return type of sizeof?
Explain what is the best way to comment out a section of code that contains comments?
What does sizeof int return?
Why c is called a mid level programming language?
With the help of using classes, write a program to add two numbers.