-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproblem-25.c
More file actions
41 lines (36 loc) · 782 Bytes
/
problem-25.c
File metadata and controls
41 lines (36 loc) · 782 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
/*write a program to find out a number from an array. if that exist show it, if not then write not found.*/
#include <stdio.h>
void main()
{
int A[20], p, s, f = 0, n;
printf("How many elements : ");
scanf("%d", &n);
printf("Enter the elements: \n");
for (p = 0; p < n; p++)
{
scanf("%d", &A[p]);
}
printf("The elements are: \n");
for (p = 0; p < n; p++)
{
printf("%d\t", A[p]);
}
printf("\nWhat you are searching for: \n");
scanf("%d", &s);
for (p = 0; p < n; p++)
{
if (s == A[p])
{
f++;
break;
}
}
if (f == 0)
{
printf("\nItem not found..");
}
else
{
printf("\n%d is located in %d position.", s, p+1);
}
}