Arithmetic In C - C Operator

C examples for Operator:Arithmetic Operator

Introduction

Common Arithmetic Operators in C

Operator Description Example
*MultiplicationfResult = fOperand1 * fOperand2;
/Division fResult = fOperand1 / fOperand2;
%Modulus (remainder) fRemainder = fOperand1 % fOperand2;
+Addition fResult = fOperand1 + fOperand2;
-Subtraction fResult = fOperand1 ? fOperand2;

Demo Code

#include <stdio.h> 

int main() { /*from  w  w w .j a v a2 s.co  m*/
   int iOperand1 = 0; 
   int iOperand2 = 0;  
   int iResult = 0; 

  
   printf("\n\tAdder Program\n"); 
   printf("\nEnter first operand: "); 
   scanf("%d", &iOperand1); 
   printf("Enter second operand: "); 
   scanf("%d", &iOperand2); 
   iResult = iOperand1 + iOperand2; 
   printf("The result is %d\n", iResult); 
}

Result


Related Tutorials