Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions 4.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@


#include<stdio.h>
#include<string.h>
int main()
{
char str[100];
int table[4][2]={{1,0},{2,0},{3,0},{3,3}};
int s=0,i,l;
printf("\nenter the string\n");
scanf("%s",str);
l= strlen(str);
for(i=0;i<l;i++)
{
s=table[s][str[i] -'0'];
}
if(s==0 || s==1 || s==2)
printf("string is valid\n");
else
printf("string is invalid\n");
}

/*Output:
enter the string
1001000010
string is invalid

enter the string
001001001
string is valid
*/