Programming, website development forum Get latest updates by RSS Follow TechnicalTalk on Twitter Follow TechnicalTalk on Facebook 
HomeSearchRecent PostsLoginRegisterContact Us

Username  
Password    
  Forgot your password?  

Which operator should be prefered first if there position are same in the precedence table?<img src=" align="bottom" style="vertical-align:middle;" /> Poll - This thread contains a Poll. First mark your answer from the options and then reply with your justification.
Question: Which operator should be prefered first if there position are same in the precedence table?Huh?
+ - 3 (100%)
- - 0 (0%)
Total Voters: 3

Pages: [1]   Go Down
 
  Email this topic  |  Print
0 Members and 1 Guest are viewing this topic.

Regarding compiler - Operator precedence

 
webmaster forum
Activity
0%
 
New Poster
Posts: 1
Topics: 1
July 05, 2008, 01:53:27 AM

Take an example of simple statement i.e.

Code:
int a=5,b=9,c=10,h=18,k;
k=h-a+c-b;
cout<<k;

as we know that +,- are at the same level in the precedence table.
Which operator should be preferred first and at last what will be the output of 'k'
« Last Edit: July 07, 2011, 10:04:44 AM by Admin »
 
webmaster forum
MikeLaw  Offline
Activity
0%
 
New Coder
Posts: 37
Topics: 2
WWW
July 06, 2008, 09:42:56 AM

Take an example of simple statement i.e.
int a=5,b=9,c=10,h=18,k;
k=h-a+c-b;
cout<<k;
as we know that +,- are at the same level in the precedence table.
Which operator should be preferred first and at last what will be the output of 'k'


Well the operators will be evaluated left to right so:
k=18-5 = 13 + 10 = 23 - 9 = 14
so 14 will be output.

Invoice Software | Billing Software | fishing luggage | fishing poles
 
webmaster forum
toby  Offline
Activity
0%
 
New Poster
Posts: 10
Topics: 2
August 17, 2008, 01:47:53 AM

The answer i come up with is 12 this is because to me, it always work out from left to right.

correct me if i am wrong, though, my programming skill has become rusty after i join the business course school "Smiley
 
webmaster forum
ManicQin  Offline
Activity
0%
 
New Poster
Posts: 3
Topics: 1
August 17, 2008, 04:15:53 AM

The answer i come up with is 12 this is because to me, it always work out from left to right.

correct me if i am wrong, though, my programming skill has become rusty after i join the business course school "Smiley

... ... With all do respect it is your mathemtical skills that are rusty ... Wink
Look at MikeLaw's answer...

or use a calculator ... shiny
 
webmaster forum
Activity
0%
 
New Poster
Posts: 7
Topics: 1
August 22, 2008, 02:12:06 PM

I see i have alot to learn
 
webmaster forum
jaincool  Offline
Activity
0%
 
Regular Coder
Posts: 50
Topics: 15
September 10, 2008, 10:05:29 AM

Buddy i think you need to brush up your maths skills...........
So here is a one more problem for you..........
a=10,b=20,x=5;
z=a+++++b--+--x
What will be the value of Z???
 shiny
 
  Email this topic  |  Print
Pages: [1]   Go Up
 
Jump to:  



Powered by SMF 1.1.15 | SMF © 2011, Simple Machines


Google visited last this page February 02, 2012, 02:38:04 AM