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 / vs
#include<stdio.h>
#include<conio.h>
void main()
int a[5],i;
int e,t=0,p=0;
clrscr();
printf("enter the array of elements/n");
for(i=0;i<5;i++)
scanf("%d",&a[i]);
clrscr();
printf("enter the element to search/n");
scanf("%d",&e);
for(i=0;i<5;i++)
{
if(a[i]==e)
{
t=1;
p=i;
}
}
if(t==1)
printf("element found--%d/n position--%d",e,p);
else
printf("element not found/n");
getch();
}
| Is This Answer Correct ? | 21 Yes | 22 No |
Post New Answer View All Answers
Write programs for String Reversal & Palindrome check
Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon
Explain how do you generate random numbers in c?
What does the message "automatic aggregate intialization is an ansi feature" mean?
What is sorting in c plus plus?
What is memcpy() function?
please give me some tips for the placement in the TCS.
Explain logical errors? Compare with syntax errors.
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }
What are the types of data files?
What are static variables in c?
program for reversing a selected line word by word when multiple lines are given without using strrev
How are Structure passing and returning implemented by the complier?
What is meant by operator precedence?
Explain data types & how many data types supported by c?