We have to make a program where you ask the user to input a sentence and a word. Then, the program will check if the word is in the sentence. If it is, it will say, "word is in the sentence", if not, it will show, "word is not in the sentence".
@MiiNiPaa, please do not provide whole solutions to homework problems for other people. They are taking the class to learn how to program, not to learn how to cheat. Your solution is also incorrect.
I think a for loop with a break to escape out if the word is not a match, nested inside a do while loop would probably work. The trick, as was pointed out by L B and vlad from moscow is that you could find a word within a word. I think the solution would be to look for a space to begin the word (represented by ' ') and then make a condition that once you find the whole word, it must be followed by either a ' ' or a '.', '!', '?', etc. If it starts with a space and ends with a space or a sentence ending character, then it's a match. Hope that helps.
Also keep in mind that if a word starts the very first word of the sentence won't have anything in front of it. An easy way to deal with that is if it's the first iteration, have it ignore the other rules (maybe like "if (i == 0) { //check to see if first char is part of the supplied word} else {//check conditions}) or something to that effect. Hope that helps.