Arithmetic Operators

C supports all the basic arithmetic operators. The following table shows all the basic arithmetic operators.
OperatorDescription
+adds two operands
-subtract second operands from first
*multiply two operand
/divide numerator by denumerator
%remainder of division
++Increment operator increases integer value by one
--Decrement operator decreases integer value by one
// C Program to demonstrate the working of arithmetic operators
#include <stdio.h>
int main()
{
    int a = 9,b = 4, c;
    
    c = a+b;
    printf("a+b = %d \n",c);

    c = a-b;
    printf("a-b = %d \n",c);
    
    c = a*b;
    printf("a*b = %d \n",c);
    
    c=a/b;
    printf("a/b = %d \n",c);
    
    c=a%b;
    printf("Remainder when a divided by b = %d \n",c);
    
    return 0;
}

No comments:

Post a Comment