-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy path17.c
More file actions
42 lines (30 loc) · 669 Bytes
/
17.c
File metadata and controls
42 lines (30 loc) · 669 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
int main()
{
int arr[100];
int size, i, num, flag;
printf("Enter size of array: ");
scanf("%d", &size);
printf("Enter elements in array: ");
for(i=0; i<size; i++)
{
scanf("%d", &arr[i]);
}
printf("\nEnter the element to search within the array: ");
scanf("%d", &num);
flag = 0;
for(i=0; i<size; i++)
{
if(arr[i]==num)
{
flag = 1;
printf("\n%d is found at position %d", num, i+1);
break;
}
}
if(flag==0)
{
printf("\n%d is not found in the array", num);
}
return 0;
}