PLease help me with this C program

Help me with is ------->The success of IEEE code-quest depends on number of times the factor is present in a given string.Help core members to find them
Factor of string is defined as a substring.In this case it’s ‘01’.
Input
First line of input contains an integer T, denoting the number of test cases. Then follows description of T cases.Each line of input is a binary form.
Output
Print the number of times the factor is present in a given string.

Constraints

1 <= S <= 100000

1 <= T <= 50

USE C PROGRAM

TEST CASE 1

INPUT

2

1001010100001

100101

OUTPUT

4

2

TEST CASE 2

INPUT

1

10001000101

OUTPUT

3

In this program the only thing you have to do is search for all ones by iterating through the string . Whenever you encounter a 1 , you then check if the next character is a 0 . If it is so increase the counter and keep on iterating the string .

can u please write the coding for the program

#include
using namespace std;
int main() {
// your code goes here
long long int t,flag,cnt;
char str[100005];
cin>>t;
while(t–)
{
cnt=0;
flag=0;//0 for 1 not found
//=1 for 1 is there and searching for 0
cin>>str;
for(register long long int i=0;str[i+1]!=’\0’;i++)
{
if(str[i]==‘1’ && str[i+1]==‘0’)
{
cnt++;
}
}
cout<<cnt<<"\n";

}
return 0;

}

It is in bad identation but the code will work .

Jus remove the your code goes here comment

You just need to check whether 1 is present in the string or not, if 1 is present then check whether the number before 1 is 0 or not, if it is 0 then increase the counter. At the end print the value of counter.Given below is the code of the problem in C language
#include<stdio.h>
int main()
{
int T,j,i,count=0,a;
char S[100001];
scanf("%d",&T);
for(i=1;i<=T;i++)
{
scanf("%s",S);
for(j=1;S[j]!=’\0’;j++)
{
a=(int)(S[j]-‘0’);
if(a==1 && (S[j-1]-‘0’) == 0)
count++;
}
printf("%d\n",count);
count=0;
}
return 0;
}

Thanks a Lot everyone .It worked!!!11

Thanks a lot

Well you can upvote h accept the answer mab be if you want . May be :slight_smile:

//