Kat H.

asked • 04/26/21

Caturday Check. Read a string (will not have spaces).

Read a string (will not have spaces). Print "true" if the word "cat" appears starting at the first or second letter. Otherwise print false.


Samples:

Input: catch Output: true
Input: scatter Output: true
Input: concatenate Output: false

Hint: you should not need to check letter by letter... use a string function that allows you to ask "where is this pattern within the string?". Use its answer to decide whether to print true or false


Code:


#include <iostream>

#include <string>

using namespace std;


//Turn off loops - you should not need them!

#define for "OhNoYouDont"

#define while "GetThatOutOfMyKitchen"



//Do not modify anything on or above the line below this

//YOUR_CODE_BELOW

int main()

{

//YOUR_CODE

}


1 Expert Answer

By:

Patrick B. answered • 04/27/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.