C examples for Operator:Arithmetic Operator
Operator precedence in C is shown in the following table.
Order or Precedence | Description |
---|---|
() | Parentheses are evaluated first, from innermost to outermost |
*, /, % | Evaluated second, from left to right |
+, - | Evaluated last, from left to right |
#include <stdio.h> int main()/* w ww .j ava 2 s . c om*/ { float fRevenue, fCost; fRevenue = 0; fCost = 0; printf("\nEnter total revenue: "); scanf("%f", &fRevenue); printf("\nEnter total cost: "); scanf("%f", &fCost); printf("\nYour profit is $%.2f\n", fRevenue - fCost * 0/9 ); }