order of precedence

i want to know the oreder of precedence when c++ program is given to c

Page 1 of 1

9 Replies - 1683 Views - Last Post: 15 August 2009 - 10:20 AM Rate Topic: -----

#1 mkameruddin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 15-August 09

order of precedence

Post icon  Posted 15 August 2009 - 08:29 AM

i want to know the oreder of precedence when c++ program is given to calculate say,12-3*5/6
Is This A Good Question/Topic? 0
  • +

Replies To: order of precedence

#2 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3124
  • View blog
  • Posts: 19,168
  • Joined: 14-September 07

Re: order of precedence

Posted 15 August 2009 - 08:31 AM

Standard order of operations:

()
^
* /
+ -
Was This Post Helpful? 0
  • +
  • -

#3 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2876
  • View blog
  • Posts: 11,051
  • Joined: 15-July 08

Re: order of precedence

Posted 15 August 2009 - 08:33 AM

The following is the order:
1) 3*5 First multiplication/division left to right
2) 15/6 Then multiplication/division left to right
3)12-(15/6) Finally addition/subtraction take place

Here's a link to help:
http://www.cpprefere...ator_precedence
http://www.cs.uml.ed...dence_chart.htm

This post has been edited by Dogstopper: 15 August 2009 - 08:35 AM

Was This Post Helpful? 0
  • +
  • -

#4 redhotfire0  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 210
  • Joined: 13-July 09

Re: order of precedence

Posted 15 August 2009 - 08:34 AM

View Postmkameruddin, on 15 Aug, 2009 - 07:29 AM, said:

i want to know the oreder of precedence when c++ program is given to calculate say,12-3*5/6

(12-((3*5)/6))
Was This Post Helpful? 0
  • +
  • -

#5 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2876
  • View blog
  • Posts: 11,051
  • Joined: 15-July 08

Re: order of precedence

Posted 15 August 2009 - 08:35 AM

View Postredhotfire0, on 15 Aug, 2009 - 07:34 AM, said:

View Postmkameruddin, on 15 Aug, 2009 - 07:29 AM, said:

i want to know the oreder of precedence when c++ program is given to calculate say,12-3*5/6

(12-((3*5)/6))

precisely ;)
Was This Post Helpful? 0
  • +
  • -

#6 redkid  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 32
  • Joined: 23-April 09

Re: order of precedence

Posted 15 August 2009 - 08:41 AM

Bless My Dear Aunt Sally!
Was This Post Helpful? 0
  • +
  • -

#7 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3124
  • View blog
  • Posts: 19,168
  • Joined: 14-September 07

Re: order of precedence

Posted 15 August 2009 - 08:47 AM

I thought it was Please Excuse My Dear Aunt Sally?
Was This Post Helpful? 0
  • +
  • -

#8 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: order of precedence

Posted 15 August 2009 - 08:49 AM

C/C++ does not have an operator for exponents.
Was This Post Helpful? 0
  • +
  • -

#9 redkid  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 32
  • Joined: 23-April 09

Re: order of precedence

Posted 15 August 2009 - 09:32 AM

View PostKYA, on 15 Aug, 2009 - 07:47 AM, said:

I thought it was Please Excuse My Dear Aunt Sally?

I have only known the other. New thing learned though. :D

This post has been edited by redkid: 15 August 2009 - 09:33 AM

Was This Post Helpful? 0
  • +
  • -

#10 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3124
  • View blog
  • Posts: 19,168
  • Joined: 14-September 07

Re: order of precedence

Posted 15 August 2009 - 10:20 AM

View PostNickDMax, on 15 Aug, 2009 - 08:49 AM, said:

C/C++ does not have an operator for exponents.



You're right, I just wrote the whole order of ops.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1