# my final questions i am new to c++

• 11-29-2008
svetlana6167
my final questions i am new to c++
1. printf("%d", 10*5/10); what is this result?

2. printf("%d", 10+5-5); what is this result?

3. a=d++ +(b=a); a=4,b=4,d=4 a=?

4. c=a+ a++ - b--; a=4,b=4 c=?

5. c=a+ ++a - b--; a=4,b=5 c=?

6. if(a==0 && b==0) printf("1);
else
if(a==0 && b==0) printf("2");
else printf("3");

(if a=1 and b=0) what is the result?
(if a=0 and b=0) what is the result?
(if a=0 and b=1) what is the result?

• 11-30-2008
Salem
1. printf("&#37;d", 10*5/10); what is this result?
Zero

2. printf("%d", 10+5-5); what is this result?
Also Zero

3. a=d++ +(b=a); a=4,b=4,d=4 a=?
If you've got a compiler, try it.

4. c=a+ a++ - b--; a=4,b=4 c=?
5. c=a+ ++a - b--; a=4,b=5 c=?
http://cboard.cprogramming.com/showt...ined+behaviour

6. dunno, bored of doing your homework.
• 11-30-2008
phantomotap
Quote:

Also Zero
O_o

Okay...

Ignore operator precedence, ignore operator associativity, ignore the fact that we are apparently discussing C or C++, how in the world are you getting zero for that?

Soma
• 11-30-2008
Elysia
I was thinking the same thing...
I was also thinking why printf is used when it's C++...
• 11-30-2008
Salem
> how in the world are you getting zero for that?
Because I couldn't give a rats ass whether the cross-forum spammer, who is too lazy to even fire up the compiler and actually punch out 5 lines of code to get the answer, either learns to think for themselves, or performs a drone-like copy of whatever is posted and subsequently fails.

I could have written
Also zero ;)
but that might have tipped them off.

So long as someone doesn't blurt out 42 (or the other right answer), then all will be well I suppose.
• 11-30-2008
svetlana6167
• 11-30-2008
Elkvis
Quote:

Originally Posted by svetlana6167

if this is for a class, that is usually the first thing they teach you.

if not. Please let us know what platform for which you are trying to write this code (windows/unix/linux/mac/etc.) and what set of development tools you are using (msvc, gcc, sun, intel, etc) and we will try to help you out.
• 11-30-2008
Elysia
Oh... my... goodness...
The first thing to do when learning C/C++ is to get a compiler and editor/IDE.
Don't expect to write code without compiling it.

And even though you were told, you continue posting on both forums. That is why they call you a cross-forum spammer.
• 11-30-2008
Salem
Well that should have been your first question then!.

As Elkvis says, if you want useful help, provide details.
• 12-01-2008
Angus
Quote:

Originally Posted by Elysia
Oh... my... goodness...
The first thing to do when learning C/C++ is to get a compiler and editor/IDE.
Don't expect to write code without compiling it.

Don't presume that the way you were taught is the way that everyone is taught. Especially when you consider from what country someone named "Svetlana" whose first language clearly isn't English might be.
• 12-01-2008
tabstop
Quote:

Originally Posted by Angus
Don't presume that the way you were taught is the way that everyone is taught. Especially when you consider from what country someone named "Svetlana" whose first language clearly isn't English might be.

I've heard of theory-intensive computer science classes where you think about what the computer might do, but that's frankly ridiculous for an intro to programming course.
• 12-01-2008
Angus
Not ridiculous, but it is beyond "very disciplined". The way they run their universities in the FSU makes it seem like they were setup by captured SS officers. I'll never forget my Russian complex variables prof. What a Nazi!
• 12-01-2008
Elysia
Quote:

Originally Posted by Angus
Don't presume that the way you were taught is the way that everyone is taught. Especially when you consider from what country someone named "Svetlana" whose first language clearly isn't English might be.

If taught already, then shame on the one.
If not taught already, then one should heed the advice and get a compiler and IDE/editor to compile and test all subsequent code.
• 12-01-2008
anon
Someone who asks questions like 4 and 5 probably doesn't know any better. I mean, ask this once but twice!!

So you don't have a compiler and are asked meaningless questions as if they meant something...
• 12-01-2008
Angus
Quote:

Originally Posted by Elysia
If taught already, then shame on the one.
If not taught already, then one should heed the advice and get a compiler and IDE/editor to compile and test all subsequent code.