Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Overview:- The purpose of this assignment is to implement a simple finite state

ID: 3013653 • Letter: O

Question

Overview:- The purpose of this assignment is to implement a simple finite state machine (more correctly, a finite state automation) using high level programming language.

Description:- Write a C++ program to implement a finite state machine which accepts a series of input strings typed in by user and determines whether or not each input contains the substring "1101".

Note the input alphabet for this assignment is I={0,1}. You must make a decision in the design of your program how to handle characters entered by a
user that do not belong in the input alphabet. Document your decision using comments in your source code.

As an example, test your machine on the string "11a01b"

The following items must be submitted
1. A finite state machine for your program
2. A listing of your source code.
3. A sample execution output screen with enough test strings to exhibit the functionality of your program


functionality of your program. ugh test strings to exhibit the C: uments and Settings trang as RCCEPTED Enter an input string 111010101 string 00010010001000100001 00010 ing 01010101101 ACCEPTED Enter an strang

Explanation / Answer

#include<stdio.h>

int main()
{
    char line[150];
    int i, j;
    printf("Enter a string: ");
    gets(line);

    for(i = 0; line[i] != ''; ++i)
    {
        while (!(line[i] >= '0' && line[i] <= '1'))
        {
            for(j = i; line[j] != ''; ++j)
            {
                line[j] = line[j+1];
            }
            line[j] = '';
        }
    }
    printf("Output String: ");
    puts(line);
    return 0;
}