Open Dain1234 opened 2 years ago
v
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"); } }