output in c programming

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2008
Posts: 1
Reputation: gayatri.saha is an unknown quantity at this point 
Solved Threads: 0
gayatri.saha gayatri.saha is offline Offline
Newbie Poster

output in c programming

 
0
  #1
Nov 3rd, 2008
1) # define cube(x)(x*x*x)
main()
int x=2. y, z;
y= cube(++x);
z= ++y + 386 / cube(++x);
printf("%d %d %d", ++x, y, z);


convert into hexadecimal
2) a = 0*aa b = a<<1
a) b=a
b) b= 2a
Last edited by gayatri.saha; Nov 3rd, 2008 at 5:01 pm. Reason: did not get appropriate reply
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 148
Reputation: devnar will become famous soon enough devnar will become famous soon enough 
Solved Threads: 16
devnar's Avatar
devnar devnar is offline Offline
Junior Poster

Re: output in c programming

 
0
  #2
Nov 3rd, 2008
Your question seems clumsily constructed and you haven't used code tags. Be specific when asking questions.
Last edited by devnar; Nov 3rd, 2008 at 4:49 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,604
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1490
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: output in c programming

 
0
  #3
Nov 4th, 2008
This is homework assignment and gayatri apparently wants us to do it for him/her.

The code you posted will have undefined behavior. cube(++x) could result in different answers on different compilers, so the ourput can not be determined exactly.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 20
Reputation: yuvaraj.tr is an unknown quantity at this point 
Solved Threads: 2
yuvaraj.tr yuvaraj.tr is offline Offline
Newbie Poster

Re: output in c programming

 
0
  #4
Nov 7th, 2008
Hi i am also new to C

I think ans may be

X=2, Y=8,z=61
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,259
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 541
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: output in c programming

 
0
  #5
Nov 7th, 2008
We wont do your homework for you, and please use code tags in future please. Check the rules and welcome guide for details.
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,117
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 282
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: output in c programming

 
0
  #6
Nov 8th, 2008
Originally Posted by Ancient Dragon View Post
The code you posted will have undefined behavior. cube(++x) could result in different answers on different compilers, so the ourput can not be determined exactly.
Why? It increments i, calls cube with the new value, then returns the answer to y. What's undefined about it? i isn't modified twice.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: output in c programming

 
0
  #7
Nov 9th, 2008
Originally Posted by WaltP View Post
Why? It increments i, calls cube with the new value, then returns the answer to y. What's undefined about it? i isn't modified twice.
That's because cube is not a function name: it's a macros. We (not me, I never use macros) have:
  1. # define cube(x)(x*x*x)
  2. int x = 2;
  3. y= cube(++x);
  4. is
  5. y = (++x*++x*++x);
But operator ++ side effect (incr x) committing point is the outer expression terminator - semicolon. So every factor may be equal to 3, 4, or 5!..
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,117
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 282
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: output in c programming

 
0
  #8
Nov 10th, 2008
My bad. I thought he wrote a function. I didn't know the macro existed, never needing it.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC