-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp14.c
More file actions
31 lines (24 loc) · 812 Bytes
/
App14.c
File metadata and controls
31 lines (24 loc) · 812 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
#include <stdio.h>
char findFirstCapital(char *str) {
if (*str == '\0') {
return '\0'; // Return null character if no capital letter found
} else {
if (*str >= 'A' && *str <= 'Z') {
return *str; // Return capital letter if found
} else {
return findFirstCapital(str + 1); // Recur to next character
}
}
}
int main() {
char str[100];
printf("Input a string including one or more capital letters: ");
fgets(str, sizeof(str), stdin);
char firstCapital = findFirstCapital(str);
if (firstCapital != '\0') {
printf("The first capital letter appears in the string is %c.\n", firstCapital);
} else {
printf("No capital letter found in the string.\n");
}
return 0;
}