I need help in writing a the following programs in C language: We want to determine whether a long string of a’s and b’s has the property that the number of a’s is even and the number of b’s is even.

Algorithm 1: Keep two binary flags, the a-flag and the b-flag. Every time an a is read, the a-flag is reversed (0 to 1, or 1 to 0); and every time a b is read, the b-flag is reversed. We start both flags at 0 and check to be sure they are both 0 at the end.

Algorithm 2: Keep only one binary flag, called the type3-flag. We read letter in two at a time. If they are the same, then we do not touch the type3-flag, since we have a factor of type1 or type2. If, however, the two letters do not match, we reverse the type3-flag. If the flag starts at 0 and if it is also 0 at the end, then the input string contains an even number of a’s and an even number of b’s.