Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I need help solving this Lab simulation, It uses white string looking for characters statements and I am very new at coding on this

Hello, I need help solving this Lab simulation, It uses white string looking for characters statements and I am very new at coding on this subject so I need help solving it. I can't seem to get the right code to get the second output?

if your input was "banana", 'b' then your output would be Found match: b

if your input was "abacus", 'c' then your output would be No match: c

An expression to detect that the first character of userInput matches firstLetter.

#include

#include

using namespace std;

int main() {

string userInput;

char firstLetter = '-';

userInput = "banana";

firstLetter = 'b';

if (/* Your solution goes here*/) {

cout << "Found match: " << firstLetter << endl;

}

else {

cout << "No match: " << firstLetter << endl;

}

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions