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 / kapil hansrajani
include<stdio.h>
#include<conio.h>
void main()
{
int a[100],i,j,n;
clrscr();
printf("Enter the number of elements : ");
scanf("%d",&n);
printf("Enter the elements: ");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("Enter the element to search : ");
scanf("%d",&j);
for(i=0;i<n;i++)
{
if(a[i]==j)
{
printf("The position of the element %d is %d ",j,i);
break;
}
}
getch();
}
| Is This Answer Correct ? | 48 Yes | 26 No |
Post New Answer View All Answers
What do mean by network ?
Why is this loop always executing once?
Explain what is the benefit of using const for declaring constants?
shorting algorithmS
Differentiate between functions getch() and getche().
Explain what is the purpose of "extern" keyword in a function declaration?
Describe the steps to insert data into a singly linked list.
struct screen_pos{ int row, col } ;move_right(cursor)struct screen_pos *cursor;{ cursor.col++; } /* This statementhas a syntax error */What is the correct statement a) cursor.col = cursor.col + 1; b) col.cursor++; c) *cursor.col++; d) pointer
Explain how can I prevent another program from modifying part of a file that I am modifying?
Why dont c comments nest?
Define VARIABLE?
If you know then define #pragma?
Give basis knowledge of web designing ...
What is malloc calloc and realloc in c?
What is string in c language?