896+ Capstone Project is Available: Whatsapp: +91-7011258995, Email: sharecodepoint@gmail.com

Program to count no of: a) +ve and –ve integers b) +ve and –ve fractions | Compiler Design Programs | Lex Programs


Compiler Design Lap Program :

%{
 #include<s;stdio.h>
 int posint=0, negint=0,posfraction=0, negfraction=0;
%}
%%
[-][0-9]+ {negint++;}
[+]?[0-9]+ {posint++;}
[+]?[0-9]*\.[0-9]+ {posfraction++;}
[-][0-9]* \.[0-9]+ {negfraction++;}
%%
int yywrap()
{
return 1;
}
main(int argc, char *argv[])
{
 If(argc!=2)
 {
 printf(“Usage: <s;./a.out> <s;sourcefile>\n”);
 exit(0);
 }
 yyin=fopen(argv[1],”r”);
yylex();
printf(“No of +ve integers=%d\n No of –ve integers=%d\n No of
+ve
fractions=%d\n No of –ve fractions=%d\n”, posint, negint,
posfraction, negfraction);
}

Sharecodepoint

Sharecodepoint is the junction where every essential thing is shared for college students in the well-defined packets of codes. We are focused on providing you the best material package like Question papers, MCQ'S, and one NIGHT STUDY MATERIAL. facebook twitter youtube instagram

Post a Comment

Previous Post Next Post

Contact Form