Arithmetic Operators In Computer Programming.


                       Arithmetic Operators

arithmetic operators


To familiarize students with arithmetic, logical and relational operators 


Turbo C IDE  


Writing a program that performs the following
       Receive two numbers as input from the user
       Find summation of two numbers using arithmetic operator
       Display on the screen to the user
Arithmetic operators are commonly used in a variety of programming languages. In C, there are five of them and they all take two OPERANDS – an expression that is required for an operator to work. For example, for 2 + 3, 2 and 3 are considered as operands. The following table shows Arithmetic Operators:
Operator Name

In addition to the division operator, C also provides modulus operator (%) which returns the remainder on dividing one integer with another. Thus the expression 10/2 yields 5, whereas 10%2 yields 0. Modulus operator cannot be applied on the float. Also using %, the sign of the remainder is always the same as the sign of numerator. Thus -5 % 2 yields -1, whereas 5 % -2 yields 1.

Step 1:

Create a New file and save it as operators.c

Step 2:

Write the following code as shown in the figure below

arithmetic operator input

Figure 12 (a): Arithmetic Operator

Step 3:

Save the file again, compile and execute it to see the output as shown in the figure below
arithmetic operator output
Figure 12 (b): Arithmetic Operator

Post a Comment