7. Lex specification program that generates a C program which takes a string “abcd” and prints the pattern

 

Lex specification program that generates a C program which takes a string “abcd” and prints the pattern

/*Write a Lex specification program that generates a C program which takes a string
“abcd” and prints the following output.
        abcd
        abc
        ab
        a
*/

%{ #include<stdio.h>
char ch;
char i,j;
%}

%%
[a-z]* { for(i='d';i>=1;--i)
      {
           for(j='a';j<=i;++j)
           {
              printf("%c ",j);
           }
          printf("\n");
      }
}
%%

int main()
{
 yylex();
 return 0;
}

//Output of the above program
Lex specification program that generates a C program which takes a string “abcd” and prints the pattern
Lex specification program that generates a C program which takes a string “abcd” and prints the pattern

Comments

  1. Struggling with coding concepts, debugging, or complex programming tasks? Academic guidance can help you understand programming fundamentals, improve problem-solving abilities, and approach assignments with greater confidence. Students seeking Online programming assignment help can receive support with languages, algorithms, data structures, and project-related concepts. Reliable assistance should focus on clear explanations, original work, and learning-oriented guidance. With the right support, students can strengthen their technical skills, manage coursework efficiently, and develop a better understanding of programming.

    ReplyDelete

Post a Comment

Popular posts from this blog

Compiler Design

10. Program in YACC to recognize the string „abbb^n, „ab^n „a^n of the langauge (a^n b^n , n>=1)