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 / aishwarya rajan
#include<iostream.h>
#include<conio.h>
void main()
{
int i,n,a[30];
char item;
cout<<"Enter the number of elements you would like to enter in the array: ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"Enter the element"<<i+1<<" :";
cin>>a[i];
}
cout<<"Enter the element you are searching for in the array:";
cin>>item;
if(a[i]==item)
cout<<"The item does exist in the array!! it is the "<<i+1<<" element!!";
else
cout<<"The item is not found in the array!!";
getch();
}
| Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
How can you increase the size of a statically allocated array?
count = 0; for (i = 1;i < = 10; i++);count = count + i; Value of count after execution of the above statements will be a) 0 b) 11 c) 55 d) array
Write a function that will take in a phone number and output all possible alphabetical combinations
Hi how many types of software editions are there and their difference (like home editions, enterprise, standard etc) can u please help me
Is c pass by value or reference?
How many types of functions are there in c?
Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent
What is the process to generate random numbers in c programming language?
any limit on the number of functions that might be present in a C program a) max 35 functions b) max 50 functions c) no limit d) none of the above
What are the uses of null pointers?
What is string function c?
An arrangement of information in memory in such a way that it can be easily accessed and processed by a programming language a) string b) data structure c) pointers d) array
"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks
What is the default value of local and global variables in c?
What is malloc and calloc?