//Downloaded From theonlinetutorials.com
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
void main()
{
int i,j,k=0,count,inc=0,n;
char name[30],open[30],ch,chh,o[30];
char op[20]={'=','+','-','*','/','%','^','&','|'};
clrscr();
textcolor(3);
cprintf("--Syntax Analyser--");
printf("\n");
printf("\n Enter Syntax");
printf("\n");
scanf("%s",name);
n=strlen(name);
for(i=0;i<n;i++)
{
ch=tolower(name[i]);
for(j=0;j<9;j++)
{
if(ch==op[j])
{
open[k]=i;
o[k]=ch;
k++;
}
}
}
for(i=0;i<k;i++)
{
count=open[i];
ch=tolower(name[count-1]);
chh=tolower(name[count+1]);
if(isalpha(ch)&&isalpha(chh)||isdigit(chh))
++inc;
}
if(k==inc)
printf("\n %s is a valid syntax",name);
else
printf("\n %s is an invalid syntax",name);
getch();
}
Not Satisfied ? Just search & get the result
Related posts:
- C program to read an English sentence and replace lowercase characters by uppercase and vice-versa. Output the given sentence as well as the case converted sentence on two different lines.
- C Program to convert the lower case letters to upper case and vice-versa
- C program to accept a string and find the sum of all digits present in the string
- C program to generate and print first N FIBONACCI numbers
- C program to find the number of integers divisible by 5 between the given range N1 and N2, where N1 < N2 and are integers. Also find the sum of all these integer numbers that divisible by 5 and output the computed results
