Write a C program to verify the String 0(0|1)*1


#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
          char str[20];
          int i,len;
          clrscr();
          printf("\n Enter the String:-");
          gets(str);
          len=strlen(str)-1;
          if((str[0]=='0' && str[len]=='1'))
                   printf("\n Validddd.....");
          else
                   printf("\n INValid String");
  getch();
}

Read more...

Write a C program to verify the string (aa|bb)*


#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
          char str[20];
          int flag=0,i;
          clrscr();

          printf("\n Enter the String:-");
          gets(str);

          if(str[0]=='\0'||(str[0]=='a' && str[1]=='a') ||( str[0]=='b' && str[1]=='b'))
          {
                   for(i=2;i<strlen(str);i+=2)
                   {
                             if((str[i]=='a' || str[i+1]=='a'))
                                      flag=1;
                             if((str[i]=='b' || str[i+1]=='b'))
                                      flag=1;
                             else
                             {
                                      flag=0;
                                      goto Next;
                             }
                   }
          Next: if(flag==1)
                             printf("\n Validddd.....");
                   else
                             printf("\n INValid String");
          }
          else
          {
                   printf("\nInvalid");
          }
          getch();
}

Read more...

Write a C Program to verify the string ab*


#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
            char str[20];
            int flag,i;
            clrscr();

            printf("\n Enter the String:-");
            gets(str);

            if(str[0]=='a')
            {
                        for(i=0;i<strlen(str);i++)
                        {
                                    if(str[i+1]=='b' || str[i+1]=='\0')
                                                flag=1;
                                    else
                                    {
                                                flag=0;
                                                break;
                                    }
                        }
                        if(flag==1)
                                    printf("\nString is Validddd.....");
                        else
                                    printf("\nInvalid String");
            }
            else
            {
                        printf("\nInvalid");
            }
            getch();
}

Read more...
Related Posts Plugin for WordPress, Blogger...

Engineering material

GTU IDP/ UDP PROJECT

GTU IDP/ UDP PROJECT

Patel free software download

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Back to TOP