Write four arithmetic operations for elementary school students in C!

Updated on educate 2024-03-21
5 answers
  1. Anonymous users2024-02-07

    It's all as simple as that, have you ever learned C!

  2. Anonymous users2024-02-06

    Please give a clear answer first: because the program stipulates that you enter an operator first, followed by two operands.

    Explain why: Please see the ** section below.

    The first scanf("%c",&oper);This sentence asks for a (note that it is) value in character format, given to the oper;

    If you enter a number, English, etc., if you enter 10 first, then the oper is 1, not 10, because %c can only read one character at a time;

    Next, enter the second and third, and the program will judge the oper further down, if the oper is equal to the - sign, it will perform subtraction, and if it is equal to the + sign, it will execute the addition;

    So if you enter an operand that doesn't match any operator, you can't do the operation.

    Is there a solution:

    Reverse the order of the statements: copy the first printf line and the first scanf line, note that the two printf lines are above the scanf, and put these two sentences after the second scanf and before the third print. You can enter 1 space + 2 space enter, and that's it.

  3. Anonymous users2024-02-05

    When the program runs, you'll be prompted first for an operator, and then for an operand. If you don't follow the prompts, of course the program will report an error.

  4. Anonymous users2024-02-04

    Here's a complete program, I tested it to meet your requirements, you're looking at it, I wrote a modular implementation, and I posted you a bit messy, and the function declaration if in one. The c file puts all the subfunctions in front of the declaration, which is not very complicated, include

    #include

    #include ""Self-defined must be enclosed in double quotation marks.

    If you use angle brackets, you will make an error.

    Included here. h file.

    Function function: Realize subtraction, addition, multiplication and division.

    void main()

    elseprintf("Typo error re-entered")}}

    #include

    #include

    void division(float a,float b)

    #include

    #include

    void multiplication(float a,float b)

    #include

    #include

    void subtraction(float a,float b)

    #include

    #include

    void sum(float a,float b)

  5. Anonymous users2024-02-03

    For example, if you define an integer variable and assign the value a=3, the value of a will be 4 after executing a++, and if ++a is the current value of a, it will only increase after a participates in the operation.

    First, if -- in the same way, change the self-increase to self-subtraction

Related questions
3 answers2024-03-21

Heada and headb are both singly linked lists with leading nodes. In this algorithm, we delete the common elements from the ith element in the heada linked list, and then insert the single-linked list heada before the jth element of the headb. >>>More

9 answers2024-03-21

The icing on the cake means to add flowers to a beautiful brocade fabric. The metaphor is slightly embellished to make the beautiful more beautiful, and the extended metaphor is further refined on the basis of the original achievement. Uttered by Song Huang Tingjian "Ode to the An".

13 answers2024-03-21

The differences between primary and secondary schools are as follows: >>>More

5 answers2024-03-21

About firefighting).

about traffic safety). >>>More

3 answers2024-03-21

Hello everyone! My name is Liu Jiayi and I am a primary school student in Year 3 (4) class. I love sports, and in the morning everyone in the classroom is playing wildly, and there is only one person running fast on the playground, and that is me. >>>More