Precedence of Operators


Warning: Undefined variable $user in /home/geekint/public_html/learn/wp-content/plugins/google-plus-authorship/google-plus-authorhip.php on line 28

Warning: Attempt to read property "ID" on null in /home/geekint/public_html/learn/wp-content/plugins/google-plus-authorship/google-plus-authorhip.php on line 28

Deprecated: Function get_bloginfo was called with an argument that is deprecated since version 2.2.0! The home option is deprecated for the family of bloginfo() functions. Use the url option instead. in /home/geekint/public_html/learn/wp-includes/functions.php on line 6114

Deprecated: Function get_the_author_ID is deprecated since version 2.8.0! Use get_the_author_meta('ID') instead. in /home/geekint/public_html/learn/wp-includes/functions.php on line 6114

Warning: Undefined variable $customprofilefield in /home/geekint/public_html/learn/wp-content/plugins/author-box-with-different-description/author_box_display.php on line 66

Deprecated: Function get_the_author_description is deprecated since version 2.8.0! Use get_the_author_meta('description') instead. in /home/geekint/public_html/learn/wp-includes/functions.php on line 6114

Warning: Undefined variable $display_author_email in /home/geekint/public_html/learn/wp-content/plugins/author-box-with-different-description/author_box_display.php on line 152

Warning: Undefined variable $display_google_profile in /home/geekint/public_html/learn/wp-content/plugins/author-box-with-different-description/author_box_display.php on line 152

Warning: Undefined variable $display_facebook_profile in /home/geekint/public_html/learn/wp-content/plugins/author-box-with-different-description/author_box_display.php on line 152

Warning: Undefined variable $display_twitter_profile in /home/geekint/public_html/learn/wp-content/plugins/author-box-with-different-description/author_box_display.php on line 152

Warning: Undefined variable $display_youtube_profile in /home/geekint/public_html/learn/wp-content/plugins/author-box-with-different-description/author_box_display.php on line 152

Warning: Undefined variable $display_linkedin_profile in /home/geekint/public_html/learn/wp-content/plugins/author-box-with-different-description/author_box_display.php on line 152

Warning: Undefined variable $display_pinterest_profile in /home/geekint/public_html/learn/wp-content/plugins/author-box-with-different-description/author_box_display.php on line 152

What is precedence of operators?

When number of operators occurs in an expression the operator which is to be evaluated first is judged by applying priority of operators. The arithmetic operators available in C are

+ used for Addition
– used for Subtraction
* used for Multiplication
/ used for Division
% used for Modulus operation

When all these are  used in an expression in a C program then the operator priority is applied in the following order

* followed by
/ followed by
% followed by
+ followed by

Example to understand the concept of priority of operators is

main()
{
int a;
a=5 + 7 – 8 * 10 / 5 % 10;
printf(“a=%d”,a);
}

The output of the above program is a=6 , This occurs as follows:

a = 5 + 6 – 80 / 5 % 10 (since * is operated first)
a = 5 + 6 – 16 % 10 (/ is operated)
a = 5 + 7 – 6 (% is calculated)
a = 12 – 6 (+ is operated)
a = 6

Editorial Team at Geekinterview is a team of HR and Career Advice members led by Chandra Vennapoosa.

Editorial Team – who has written posts on Online Learning.