D Que4.cpp
D Que4.cpp
h>
/**
* This function calculates the count of all the elements in B having 'A' or 'a' as
their first character.
*
* Parameters:
* N (INTEGER): The size of the array B.
* B (STRING ARRAY): The given string array.
*
* Returns:
* INTEGER: The number of strings in the array B that start with 'a' or 'A'.
*/
int spotAstring(int N, std::vector<std::string> B) {
int count = 0;
for (int i = 0; i < N; i++) {
if (B[i][0] == 'a' || B[i][0] == 'A') {
count++;
}
}
return count;
}
int main() {
int N;
std::cout << "Enter the size of the array: ";
std::cin >> N;
std::vector<std::string> B(N);
std::cout << "Enter the strings: ";
for (int i = 0; i < N; i++) {
std::cin >> B[i];
}
return 0;
}