write a program to search for an element in a given array.
If the array was found then display its position otherwise
display appropriate message in c language
Answer Posted / bishwas bidari
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i;
int ele,temp=0,pos=0;
clrscr();
printf("enter the array elements\n");
for (i=0; i<5; i++)
{
scanf("%d",&a[i]);
}
printf("Enter the element to be search\n");
scanf("%d",&ele);
/* searching for the element*/
for (i=0; i<5; i++)
{
if (a[i]==ele)
{
temp=1;
pos=i;
}
}
if (temp==1)
printf("Element found %d , position==%d",ele,pos);
else
printf("Element not found\n");
}
| Is This Answer Correct ? | 85 Yes | 52 No |
Post New Answer View All Answers
In this assignment you are asked to write a multithreaded program to find the duplicates in an array of 10 million integers. The integers are between -5000,000 to 5000,000 and are generated randomly. Use 10 threads, each thread works on 1000,000 integers. Compare the time needed to accomplish the task with single thread of execution program. Do not include the time to fill the array with integers in the execution time.
What is the total generic pointer type?
What is indirection in c?
Explain what is meant by 'bit masking'?
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
What are the advantages of c language?
When is a void pointer used?
What are the disadvantages of a shell structure?
Can we use visual studio for c?
Simplify the program segment if X = B then C ← true else C ← false
Explain what are compound statements?
What does a pointer variable always consist of?
What is a null pointer assignment error? What are bus errors, memory faults, and core dumps?
How is pointer initialized in c?
What is use of integral promotions in c?