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

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.Help me out in this code.this code is accepting string 900 whereas character are 0 and 1 #include  #include  using namespace std; int main() { char string[100]; char transaction[50][2]; int count_01 = 0, count_10 = 0; cout << "enter the String::"; cin >> string; int length = strlen(string); for (int i = 0; i < length-1; i++) { transaction[i][0] = string[i]; transaction[i][1] = string[i + 1]; if (string[i] == '0' && string[i + 1] == '1') count_01++; else if(string[i] == '1' && string[i + 1] == '0') count_10++; } if (count_01 == count_10) cout << " string accepted "; else cout << " string Rejected "; return 0; } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!