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();
}

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