A symbol that specifies an operation between the operands. Often written between the operands.
Example: 1 + 2; here, "+" is the operator, and the numbers are the operands.
arithmatic operator +,-,*,/,% assigment oprator == logical operator &,|,^,&&,,! bitwise opertor &,|,^ left shift << right shift >> left shift zero fill << assignment operator +=,-=,*=,/=
// made by vijay NITJ #include<iostream.h> #include<string.h> #include<stdio.h> #include<math.h> int precedence(char); void main() { char q[20]; char p[20]; char stack[20]; int tp=-1,ts=0; stack[0]='('; cout<<stack; int i=0, f=1; cout<<"enter the prefix expression "; gets(q); int l=strlen(q); q[l]=')'; while(ts!=-1) { if(q[i]>=47 && q[i]<=58 q[i]<=65 && q[i]<=90 q[i]<=97 && q[i]>=122) { p[++tp]=q[i]; } else if(q[i]=='(') stack[++ts]=q[i]; else if(q[i]=='+' q[i]=='-' q[i]=='*' q[i]=='/') { if(stack[ts]=='(') stack[++ts]=q[i]; else { while(stack[ts]!='(') { int p1=precedence(q[i]); int p2=precedence(stack[ts]); if(p2>=p1) p[++tp]=stack[ts--]; else { f=0; break; } } if(f==0) stack[++ts]=q[i]; } } else if(q[i]==')') { while(stack[ts]!='(') { p[++tp]=stack[ts--]; } ts--; } i++; } for(int j=0; j<=tp;j++) { cout<<p[j]; } //precedence program int precedence(char a) { if(a=='+' a=='-') return 1; else if(a=='*' a=='/') return 2; }
I am a data oprator
Pressumably, the designers of Java thought this would lead to confusing code.
arithmatic operator +,-,*,/,% assigment oprator == logical operator &,|,^,&&,,! bitwise opertor &,|,^ left shift << right shift >> left shift zero fill << assignment operator +=,-=,*=,/=
// made by vijay NITJ #include<iostream.h> #include<string.h> #include<stdio.h> #include<math.h> int precedence(char); void main() { char q[20]; char p[20]; char stack[20]; int tp=-1,ts=0; stack[0]='('; cout<<stack; int i=0, f=1; cout<<"enter the prefix expression "; gets(q); int l=strlen(q); q[l]=')'; while(ts!=-1) { if(q[i]>=47 && q[i]<=58 q[i]<=65 && q[i]<=90 q[i]<=97 && q[i]>=122) { p[++tp]=q[i]; } else if(q[i]=='(') stack[++ts]=q[i]; else if(q[i]=='+' q[i]=='-' q[i]=='*' q[i]=='/') { if(stack[ts]=='(') stack[++ts]=q[i]; else { while(stack[ts]!='(') { int p1=precedence(q[i]); int p2=precedence(stack[ts]); if(p2>=p1) p[++tp]=stack[ts--]; else { f=0; break; } } if(f==0) stack[++ts]=q[i]; } } else if(q[i]==')') { while(stack[ts]!='(') { p[++tp]=stack[ts--]; } ts--; } i++; } for(int j=0; j<=tp;j++) { cout<<p[j]; } //precedence program int precedence(char a) { if(a=='+' a=='-') return 1; else if(a=='*' a=='/') return 2; }