Dain1234 / Theory-of-computation

0 stars 0 forks source link

String belong to grammer #4

Open Dain1234 opened 2 years ago

Dain1234 commented 2 years ago

Screenshot (42)

Dain1234 commented 2 years ago

v

Dain1234 commented 2 years ago

include

include

void main(){ char s[100]; int i,flag; int l; printf("enter a string to check:"); scanf("%s",s); l=strlen(s); flag=1; for(i=0;i<l;i++) { if(s[i]!='0' && s[i]!='1') { flag=0; } } if(flag==1) printf("string is Valid\n"); else printf("string is Not Valid\n"); if(flag==1) { if (s[0]=='0'&&s[l-1]=='1') printf("string is accepted\n"); else printf("string is Not accepted\n"); } }