Newbie here again. Working on homework again and loking for some hints. My instructor suggested the concept is a "state engine" and I have searched the boards and google without finding much.
Instructions are to write a program that reads input and count all occurances of the letters "is" in that order. ex. Mississippi would be 2.
Here is my code so far. I am getting a count on all "i" and "s". Trying to figure out how to code it so its:
Check for "i"
check next letter
if "s" add 1 to count, if not continue checking.
exit at #
Code:#include <stdio.h> int main(void) { char ch; char next_ch; int is_count = 0; printf("Key in your word or phrase: \n"); while ((ch = getchar()) !='#') { if (ch == 'i') is_count++; if (ch == 's') is_count++; } printf("\"is\" count %d\n", is_count); getchar(); getchar(); return 0; }



LinkBack URL
About LinkBacks




