Monday, December 17, 2018
Tuesday, December 11, 2018
string belongs to the given grammar or not
C Program for implementation of language given belowE-> TE’#include<stdio.h> #include<conio.h> #include<string.h> #include<process.h> void e(); void e1(); void t(); void t1(); void f(); int ip=0; static char s[10]; void main() { char k; int i; ip=0; clrscr(); printf("enter the string:\n "); scanf("%s",s); printf("the string is : %s\n",s); e(); if(s[ip]=='$') printf("String is accepted "); getch(); } void e() { t(); e1(); return; } void t() { f(); t1(); // return; } void e1() { if(s[ip]=='+') { ip++; t(); e1(); } return; } void t1() { if(s[ip]=='*') { ip++; f(); t1(); } return; } void f() { if(s[ip]=='(') { ip++; e(); if(s[ip]==')') ip++; else printf("error closed paranthesis expected"); } else if(s[ip]=='i') ip++; else printf("id expected "); return; }
E’-> +TE’ | epsilon
T-> FT’
T’-> *FT’ | epsilon
F-> (E) | i
Thursday, December 6, 2018
Identifying the given number is valid number or not
#include <stdio.h>
#include<string.h>
int main()
{
char a[500];
int i,l,c=1,k=0;
scanf("%s",a);
l=strlen(a);
if(a[0]=='+'||a[0]=='-'||(a[0]>='0'&&a[0]<='9'))
{
for(i=1;i<l;i++)
{
if(a[i]=='.')
{
k++;
if(k>1)
{
printf("invalid");
return 0;
}
}
else if((a[i]>='0'&&a[i]<='9'))
c++;
else
break;
}
if(c==l-1)
printf("valid");
else
printf("invalid");
}
else
printf("invalid");
return 0;
}
Subscribe to:
Posts (Atom)
DBMS class materials click here to join the class room click here https://www.youtube.com/channel/UC93Sqlk_tv9A9cFv-QjZFAQ
-
Design LALR Bottom up Parser. <parser.l> %{ #include<stdio.h> #include "y.tab.h" %} %% [0-9]+ {yylval...
-
Lucky Gifts "Planet Kids Entertainment Fair" is back to delight kids and parents. The Fair will have non-stop entertainment w...