The Eduladder is a community of students, teachers, and programmers just interested to make you pass any exams. So we help you to solve your academic and programming questions fast.
Watch related videos of your favorite subject.
Connect with students from different parts of the world.
See Our team
Wondering how we keep quality?
Got unsolved questions?

Model-Question-Paper--PROGRAMMING-IN-C-AND-DATA-STRUCTURES--14PCD1314PCD23-->View question

Taged users:

Likes:
Be first to like this question

Dislikes:
Be first to dislike this question
In at this program we are counting positive,negetive as well as fractions little bit of change in at this program can help you to count all the negative numbers. So the program goes here
lex file: a.l

%{
int postiveno=0;
int negtiveno=0;
int positivefractions=0;
int negativefractions=0;
%}

DIGIT [0-9]
%%

\+?{DIGIT}+                              postiveno++;
-{DIGIT}+                                  negtiveno++;

\+?{DIGIT}*\.{DIGIT}+            positivefractions++;
-{DIGIT}*\.{DIGIT}+                negativefractions++;
. ;
%%

main()
{
yylex();
printf("\nNo. of positive numbers: %d",postiveno);
printf("\nNo. of Negative numbers: %d",negtiveno);
printf("\nNo. of Positive fractions: %d",positivefractions);
printf("\nNo. of Negative fractions: %d\n",negativefractions);
}

Output:

nn@linuxmint ~ \$ lex a.l
nn@linuxmint ~ \$ gcc lex.yy.c -ll
nn@linuxmint ~ \$ ./a.out<a.txt

No. of positive numbers: 2
No. of Negative numbers: 3
No. of Positive fractions: 4
No. of Negative fractions: 5
nn@linuxmint ~ \$

// Input file: a.txt
+12,-123,1.1,-1.1,12,-2,-3,2.1,3.2,5.1,-5.5,-6.1,-7.7,-8.8

Likes:
Be first to like this answer

Dislikes:
Be first to dislike this answer

### Watch more videos from this user Here

Learn how to upload a video and start earning here

Lets together make the web is a better place

We made eduladder by keeping the ideology of building a supermarket of all the educational material available under one roof. We are doing it with the help of individual contributors like you, interns and employees. So the resources you are looking for can be easily available and accessible also with the freedom of remix reuse and reshare our content under the terms of creative commons license with attribution required close.

You can also contribute to our vision of "Helping student to pass any exams" with these.