[code]
Code:
#include<stdio.h>
#include<stdlib.h>
#define MAXCOLS 80
int main()
{
int num_operand =5;
int num_operatr = 4;
int strglen=num_operand+num_operatr;
char operand;
int i, j;
char string[MAXCOLS];
char getexp[strglen];
char a[]={'5','3','2','3','4','2','5','4','6','8'};
printf("Enter a command of the sort A+B*C_D*E:\n");
fgets(getexp, sizeof getexp, stdin);
for(j=0; getexp[j] != '\0'; j++)
{
operand=getexp[j];
if(operand >= 'A' && operand <='Z')
string[j]=a[operand-(int)('A')];
else
string[j]=(char)operand;
}
string[j] ='\0';
printf("Expression\n");
//for(i=0; i<strglen; ++i)
printf("%s", string);
getchar();
return 0;
}
/* my outout
Enter a command of the sort A+B*C_D*E:
A+B+C
Expression
5+3+2
*/
ssharish2005