I have an urgent assignment. It would be so great if anyone could help me with the codes of this as I am not able to understand this:

Here's the question:

Enumerations make it possible to define a new type that contains a limited number of values e.g. the TokenType
We define it in the following way:
typedef enum
Enumeration definitions have to be included in header files.
We can treat enumeration values as integer constants e.g.
TokenType en1=ERROR;
int one=9, two=8;
char token[20]=" add ";
if (strstr(token,"add"))
switch (en1)

case ADD: return(one+two);
case MULTIPLY: return (one*two);
default: break;

  1. Implement the method getNextToken that reads a token from the standard input and determines its type.
    The token is stored in the tk parameter. The len specifies the number of elements in the tk array.
    TokenType getNextToken(char tk[], int len);
    The values should be calculated using the following rules:
    “add” or “+”  ADD
    “equals” or “=”  EQUALS,
    “subtract” or “-“ SUBTRACT
    “prev” or “prev_result  PREV
    Any floating point or integer number NUMBER
    In all other cases  WORD
    To read values you can use scanf. To limit the length of a token use e.g. code presented during a lecture.

  2. Implement the lineCalc function that gets tokes provided by getNextToken and evaluates their value.
    static float prevResult;
    char * lineCalc(void)

static char result2Return[20];
float value;
// implementation of the function
sprint(result2Return, “%4.2f”, value); // to convert a number to a string with the specified precision.
return result2Return;

 All tokens categorized as WORD are ignored by the evaluator.
 If more than more than one operator follow each other then last is valid
 An expression ends with the EQUALS token.
 The value of the PREV token is the value of the prevResult variable.
 “2 + 7 =“ has the value: “9”
 “ 5 - add 8.1 = “ has the value: “13.1”
 “ bread 3.5 plus butter 5.1 + milk 2.5 equals ” has the value: “11.1”
 “ prev minus 1 = ”  has the value: 10.1

  1. Implement a program that reads tokens from standard input and prints their value on the monitor.
     Add MULTIPLY and DIVIDE tokens and appropriate operators.
     Take into account the priority of operators

I found no question here. There's the assignment but no question. Also, this is not urgent as in "my socks are on fire."

Read https://www.daniweb.com/programming/threads/435023/read-this-before-posting-a-question then try again by showing your work, where you are stuck and then the question.

I think it's worth saying that folk rarely respond with a full ready to submit program code for you to pass off as yours. Sometimes new members don't know that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.