Untitled
unknown
plain_text
2 years ago
939 B
8
Indexable
#include<stdio.h>
#include<string.h>
char input[10];
int i=0,error=0;
void E();
void T();
void ();
void Tprime();
void F();Eprime
void main()
{
printf("Enter an arthematic expression:\n");
gets(input);
E();
if(strlen(input)==i&&error==0)
printf("\nAccepted...!!!");
else
printf("\n Rejected...!!!");
}
void E()
{
T();
Eprime();
}
void Eprime()
{
if(input[i]=='+')
{
i++;
T();
Eprime();
}
}
void T()
{
F();
Tprime();
}
void Tprime()
{
if(input[i]=='*')
{
i++;
F();
Tprime();
}
}
void F()
{
if(input[i]=='(')
{
i++;
E();
}
if(input[i]==')')
{
i++;
}
elseif(isalpha(input[i])
{
i++;
while(isalnum(input[i]||input[i]=='-')
i++;
}
else
error=1;
}Editor is loading...
Leave a Comment