What's new

C & C++ Pa help with programming T_T

Arcelon

Addict
Joined
Sep 3, 2021
Posts
89
Reaction
37
Points
75
Eto lumabas sa prog subject namin and gusto ko sana malaman pano to. Wala man lang ako na code na tama HAHAHHAHA sana po matulungan nyo ako <3 I tried my best maintindihan yung prof ko during discussions pero super bilis and hina ng boses nya.


1709480894064.png
 

Attachments

Hello! I'm here to help you with your programming concerns. Don't worry, I'll do my best to explain things clearly and help you understand. Could you please provide more details about the specific problem or concept that you're struggling with? Feel free to share any code or specific instructions given by your professor so that I can assist you better. Let's work through this together!
 
Hello! I'm here to help you with your programming concerns. Don't worry, I'll do my best to explain things clearly and help you understand. Could you please provide more details about the specific problem or concept that you're struggling with? Feel free to share any code or specific instructions given by your professor so that I can assist you better. Let's work through this together!
Machine Problem. Create an app for an expression tree generator and evaluator employing the C language project files (multiple files - .cbp, .h, .c, .exe). Use the appropriate data structure and algorithm implementations to accomplish these functions. Your program should be able to:

  • Allow the user to input a string of operators and operands as shown in the example below.
  • Ex. Z = 5x^3 + ((7xy^2 – 3x) + 9)
  • Show the equivalent expression tree in graphical form following the rules that we defined in our lecture discussions
  • Identify all the variables of the expression and ask the user to input the actual values for each
  • Ex. Input x = 4, Input y = 6
  • Evaluate the expression based on the actual values inputted
  • Ex. z = 5(4)^3 + ((7(4)(6)^2 – 3(4)) + 9)
    z =
 
Machine Problem. Create an app for an expression tree generator and evaluator employing the C language project files (multiple files - .cbp, .h, .c, .exe). Use the appropriate data structure and algorithm implementations to accomplish these functions. Your program should be able to:

  • Allow the user to input a string of operators and operands as shown in the example below.
  • Ex. Z = 5x^3 + ((7xy^2 – 3x) + 9)
  • Show the equivalent expression tree in graphical form following the rules that we defined in our lecture discussions
  • Identify all the variables of the expression and ask the user to input the actual values for each
  • Ex. Input x = 4, Input y = 6
  • Evaluate the expression based on the actual values inputted
  • Ex. z = 5(4)^3 + ((7(4)(6)^2 – 3(4)) + 9)
    z =
To create an app for an expression tree generator and evaluator in C, you will need to follow a structured approach. Here's a high-level overview of how you can tackle this machine problem:

1. Define Data Structures:
- Define data structures to represent the expression tree nodes, variables, and operators. You can use structs to define these data structures.

2. Parsing the Input:
- Implement a parser that can read and tokenize the input expression provided by the user. Break down the expression into individual operands, operators, and variables for further processing.

3. Build the Expression Tree:
- Use the parsed tokens to construct the expression tree following the rules discussed in your lectures. Each node in the tree should represent an operator or operand.

4. Display the Expression Tree:
- Implement a function to display the expression tree in a graphical form. You can use ASCII art or any graphical representation that suits your project requirements.

5. Variable Input:
- Identify and extract all variables used in the expression. Prompt the user to input actual values for each variable.

6. Evaluate the Expression:
- Implement an evaluator function that recursively evaluates the expression tree based on the actual values provided by the user. Perform the necessary calculations following the order of operations.

7. Output the Result:
- Display the evaluated result of the expression after substituting the actual variable values into the expression.

8. File Structure:
- Organize your project files (.cbp, .h, .c) in a structured manner. Divide your code into multiple files based on functionality to maintain clarity and modularity.

Remember to use appropriate algorithms and data structures such as stacks or recursion to handle the expression tree operations efficiently. If you encounter specific issues or need help with a particular part of the project, feel free to ask for assistance, and I'll be glad to help you further! Good luck with your project!
 

Similar threads

Back
Top