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

This program in c++ should take string from user and check whether count of 01 i

ID: 3744728 • Letter: T

Question

This program in c++ should take string from user and check whether count of 01 is equivalent to count of 10 .2d array is used to store transition table. in transition table store characters 0 and 1 and states..But this code is accepting 01 whereas it should reject because count of 01 is 1 and count of 10 is 0.Help me out in this code.

#include<iostream>

#include <cstring>

using namespace std;

int main()

{

char string[100];

char transaction[10][2];

int count_01,count_10;

cout<<"enter the String::";

cin>>string;

int length=strlen(string);

for(int i=0;i<length;i++)

{

transaction[i][0]=string[i];

transaction[i][1]=string[i+1];

if(string[i]=='0'&&string[i+1]=='1')

count_01++;

}

for(int i=0;i<length;i++)

{

if(string[i]=='1'&&string[i+1]=='0')

count_10++;

}

if(count_01==count_10)

cout<<" string accepted ";

else

cout<<" string Rejected ";

return 0;

}

Explanation / Answer

#include #include using namespace std; int main() { char string[100]; char transaction[50][2]; int count_01, count_10; cout > string; int length = strlen(string); for (int i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote