Pages

Pages

Select Lines Starting with 'm' - Lex Program - Compiler Design

Program:

%{
%}
reg1 ^m.*\n

%%
{reg1} {ECHO;}
. ;
%%
Output:

( input file : c1.c

#include<stdio.h>
main ()
{
    int i,n,fact=1;
    printf("Enter the number: ");
    scanf("%d",&n);            //inputing the number
    for(i=1;i<=n;i++)        /* finding factorial */
    {
        fact = fact*i;
            }
    printf("Factorial=%d\n",fact);
}

)


nn@linuxmint ~ $ lex l7.lex
nn@linuxmint ~ $ gcc lex.yy.c -lfl
nn@linuxmint ~ $ ./a.out <c1.c

main ()











nn@linuxmint ~ $

1 comment:

  1. This site and this post very help full for all visitor any can get help by read this content and site.
    Membership Card Manufacturers
    PVC Plastic Card Printing

    ReplyDelete