Operators Precedence in C

C Programming Language Operators and Enums in C Language (Article) Operators and Enums in C Language (Program)

795

Program:

#include"stdio.h"
int main()
{
	int a = 28;
   int b = 20;
   int c = 16;
   int d = 8;
   int e;
 
   e = (a + b) * c / d;      // ( 30 * 15 ) / 5
   printf("Value of (a + b) * c / d is : %d\n",  e );

   e = ((a + b) * c) / d;    // (30 * 15 ) / 5
   printf("Value of ((a + b) * c) / d is  : %d\n" ,  e );

   e = (a + b) * (c / d);   // (30) * (15/5)
   printf("Value of (a + b) * (c / d) is  : %d\n",  e );

   e = a + (b * c) / d;     //  20 + (150/5)
   printf("Value of a + (b * c) / d is  : %d\n" ,  e );
  
   return 0;
}

Output:

Value of (a + b) * c / d is : 96
Value of ((a + b) * c) / d is  : 96
Value of (a + b) * (c / d) is  : 96
Value of a + (b * c) / d is  : 68
Press any key to continue . . .

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.