adspace
write a program that reads a series of strings and prints only
those strings begging with letter "b"
Answer Posted / Shumaila Haque
Here's a simple C++ code snippet that demonstrates how to print strings starting with the letter 'b':n```cppn#include <iostream>n#include <vector>n#include <algorithm>nnstd::vector<std::string> filterStrings(const std::vector<std::string>& input) {n std::vector<std::string> result;n for (const auto& str : input) {n if (str[0] == 'b') {n result.push_back(str);n }n }n return result;n}nnint main() {n std::vector<std::string> strings = {"apple", "banana", "blueberry", "cherry"};n auto filteredStrings = filterStrings(strings);n for (const auto& str : filteredStrings) {n std::cout << str << ' ';n }n return 0;n}n``
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Question 1: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date. *This Should Be Done IN C++