programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Ron McLeod
• Paul Clapham
• Devaka Cooray
• Liutauras Vilda
Sheriffs:
• Jeanne Boyarsky
• paul wheaton
• Henry Wong
Saloon Keepers:
• Stephan van Hulst
• Tim Holloway
• Tim Moores
• Carey Brown
• Mikalai Zaikin
Bartenders:
• Lou Hamers
• Piet Souris
• Frits Walraven

# am confusing in operator precednce pls explain me

Greenhorn
Posts: 17
• Number of slices to send:
Optional 'thank-you' note:
1+2*3%4+5/4

Ranch Hand
Posts: 123
• Number of slices to send:
Optional 'thank-you' note:

1+2*3%4+5/4

= 1+((2*3)%4)+(5/4)
= 1+(6%4)+1
= 1+2+1
= 4

As the precedence of * / % are same they will calculate left to right , that's why 2*3 and 5/4 will be the first operation , then 6%4 and then the sum of all three.

 You can't expect to wield supreme executive power just because We need your help - Coderanch server fundraiser https://coderanch.com/wiki/782867/Coderanch-server-fundraiser