Answers for "Find the maximum consecutive 1's in a string of 0's and 1's."

0

Find the maximum consecutive 1's in a string of 0's and 1's.

#include<stdio.h>
#include<string.h>
void main()
{

    printf("Enter the string of '0's and '1's ");
    char str[100];
    int count1=0;
    scanf("%s", str);

    for(int i=0;i<strlen(str);i++)
    {

        if(str[i] == '1')
        {
            count1++;
        }

    }
    printf("Max number of consecutive 1's is %d",count1);

}
Posted by: Guest on June-04-2021

Code answers related to "Find the maximum consecutive 1's in a string of 0's and 1's."

Browse Popular Code Answers by Language