#include #include void main() { int chr=0,num=0,symb=0,J=0,R=0,oper=0; int n; char c; FILE *abt; abt=fopen("file.txt","w"); printf("\n Enter the Expression"); while((c=getchar())!='\n') fputc(c,abt); fclose(abt); abt=fopen("file.txt","r"); while(!feof(abt)) { c=getc(abt); n=toascii(c); if(n>64&&n<91||n>96&&n<122) chr++; if(n>47&&n<58) num++; if(n==33||n==37||n==42||n==43||n==45||n==47) oper++; else if(n>32&&n<48) symb++; if(n==40) J++; if(n==41) R++; } fclose(abt); printf("\n The given expression contains"); printf("\n operands %d\n constants %d\n symbol %d\n operator %d\n",chr,num,symb,oper); if(J==R) printf("Paranthesis is balanced"); else printf("Paranthesis is unbalanced"); }
|
No feedbacks found. Be the first to respond and make money from revenue sharing program.
|