-
Notifications
You must be signed in to change notification settings - Fork 16
/
16.c
38 lines (31 loc) · 727 Bytes
/
16.c
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
#include <stdio.h>
int find(const char array[], char character)
{
for (int i = 0; array[i] != '\0'; i++)
{
if (array[i] == character)
{
return 1;
}
}
return 0;
}
int main()
{
char inputArray[100];
char targetCharacter;
printf("Enter a character array: ");
scanf("%s", inputArray);
printf("Enter a character to search for: ");
scanf(" %c", &targetCharacter);
int result = find(inputArray, targetCharacter);
if (result == 1)
{
printf("The character '%c' is found in the array.\n", targetCharacter);
}
else
{
printf("The character '%c' is not found in the array.\n", targetCharacter);
}
return 0;
}